using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.Linq; using System.Web; using EnVisage.Code; namespace EnVisage.Models { public class GLAccountModel : IBaseModel { public Guid Id { get; set; } [Required] [MaxLength(100)] [Display(Name="GL Account Name")] public string Name { get; set; } [Required] [MaxLength(20)] [Display(Name = "GL Account Number")] public string GLNumber { get; set; } [Display(Name = "Number of Expenditures")] public int ExpenditureCount { get; set; } [Display(Name = "Number of Clients")] public int ClientCount { get; set; } /// /// Casts a obect to the object of type . /// /// A object. /// A object filled with data from db. public static explicit operator GLAccountModel(GLAccount obj) { if (obj == null) return null; var model = new GLAccountModel { Id = obj.Id, Name = obj.Name, GLNumber = obj.GLNumber, }; model.TrimStringProperties(); return model; } /// /// Copies data from model to DAL object. /// /// A target DAL object. public void CopyTo(GLAccount dbObj) { if (dbObj == null) throw new ArgumentNullException(); dbObj.Name = Name; dbObj.GLNumber = GLNumber; } } /// /// An UI representation of client to be displayed as list items /// public class GLAccountListModel { public Guid Id { get; set; } public string Name { get; set; } public string GLNumber { get; set; } public int ExpenditureCount { get; set; } public int ClientCount { get; set; } } }