80 lines
2.0 KiB
C#
80 lines
2.0 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel.DataAnnotations;
|
|
|
|
namespace EnVisage.Models
|
|
{
|
|
public class ClientModel : IBaseModel<Client>
|
|
{
|
|
public Guid Id { get; set; }
|
|
|
|
[Required]
|
|
[MaxLength(100, ErrorMessage = "Client name should not exceed 100 characters")]
|
|
public string Name { get; set; }
|
|
|
|
public Guid? GLAccountId { get; set; }
|
|
|
|
[Display(Name = "Number")]
|
|
public string ClientNumber { get; set; }
|
|
|
|
[Display(Name = "Number of Projects")]
|
|
public int ProjectsCount { get; set; }
|
|
|
|
[Required(ErrorMessage = "Business Unit is required")]
|
|
public IList<Guid> CompanyId { get; set; }
|
|
|
|
/// <summary>
|
|
/// Copies data from model to DAL object.
|
|
/// </summary>
|
|
/// <param name="dbObj">A target DAL object.</param>
|
|
public void CopyTo(Client dbObj)
|
|
{
|
|
if (dbObj == null)
|
|
throw new ArgumentNullException();
|
|
|
|
dbObj.Name = Name;
|
|
dbObj.GLAccountId = GLAccountId;
|
|
dbObj.ClientNumber = ClientNumber;
|
|
}
|
|
}
|
|
|
|
public class ClientApiModel
|
|
{
|
|
public Guid Id { get; set; }
|
|
public Guid? GLAccountId { get; set; }
|
|
public string Name { get; set; }
|
|
public string ClientNumber { get; set; }
|
|
|
|
#region Constructors
|
|
|
|
public ClientApiModel()
|
|
{
|
|
|
|
}
|
|
|
|
public ClientApiModel(ClientListModel client)
|
|
: this()
|
|
{
|
|
if (client == null)
|
|
throw new ArgumentNullException("client");
|
|
|
|
Id = client.Id;
|
|
GLAccountId = client.GLAccountId;
|
|
Name = client.Name;
|
|
ClientNumber = client.ClientNumber;
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
|
|
/// <summary>
|
|
/// An UI representation of client to be displayed as list items
|
|
/// </summary>
|
|
public class ClientListModel: ClientApiModel
|
|
{
|
|
public int ProjectsCount { get; set; }
|
|
public IList<string> Companies { get; set; }
|
|
public string GlAccount { get; set; }
|
|
}
|
|
|
|
} |