using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.Linq; using System.Web; using EnVisage.Code; namespace EnVisage.Models { public class UOMModel : IBaseModel { public Guid Id { get; set; } [Required] [MaxLength(50)] [Display(Name="Unit of Measure Name")] public string Name { get; set; } [Display(Name = "Value")] public decimal UOMValue { get; set; } [Display(Name = "Number of Expenditure Categories")] public int ExpenditureCategoryCount { get; set; } /// /// Casts a obect to the object of type . /// /// A object. /// A object filled with data from db. public static explicit operator UOMModel(UOM obj) { if (obj == null) return null; var model = new UOMModel { Id = obj.Id, Name = obj.Name, UOMValue = obj.UOMValue, ExpenditureCategoryCount = obj.ExpenditureCategory.Count }; model.TrimStringProperties(); return model; } /// /// Copies data from model to DAL object. /// /// A target DAL object. public void CopyTo(UOM dbObj) { if (dbObj == null) throw new ArgumentNullException(); dbObj.Name = Name; dbObj.UOMValue = UOMValue; } } }