using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; namespace EnVisage.Models { public class ClientModel : IBaseModel { 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 CompanyId { get; set; } /// /// Copies data from model to DAL object. /// /// A target DAL object. 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 } /// /// An UI representation of client to be displayed as list items /// public class ClientListModel: ClientApiModel { public int ProjectsCount { get; set; } public IList Companies { get; set; } public string GlAccount { get; set; } } }