using EnVisage.Code; using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.Linq; using System.Web; namespace EnVisage.Models { public class CalculatesCategoryModel { #region Classes and enums public enum FactorTypes { [DisplayValue("Multipiy")] Multipiy = 0, [DisplayValue("Divide")] Divide = 1, } #endregion public System.Guid Id { get; set; } public System.Guid ParentId { get; set; } [Required] [Display(Name = "Expenditure")] public System.Guid ChildId { get; set; } [Required] [Display(Name = "Factor Type")] public Nullable FactorType { get; set; } [Required] [Display(Name = "Factor")] public Nullable FactorInt { get; set; } [Required] [Display(Name = "Process Order")] public Nullable ProcessOrder { get; set; } public virtual ExpenditureCategory ExpenditureCategory { get; set; } /// /// Casts a obect to the object of type . /// /// A object. /// A object filled with data from db. public static explicit operator CalculatesCategoryModel(Expenditure2Expenditure obj) { if (obj == null) return null; var model = new CalculatesCategoryModel { Id = obj.Id, ParentId = obj.ParentId, ChildId = obj.ChildId, FactorType = (FactorTypes?)obj.FactorType, FactorInt = (decimal)obj.FactorInt, ProcessOrder = obj.ProcessOrder, ExpenditureCategory = obj.ChildExpenditureCategory }; return model; } /// /// Copies data from model to DAL object. /// /// A target DAL object. public void CopyTo(Expenditure2Expenditure dbObj) { if (dbObj == null) throw new ArgumentNullException(); dbObj.ParentId = ParentId; dbObj.ChildId = ChildId; dbObj.FactorType = (int?)FactorType; dbObj.FactorInt = FactorInt; dbObj.ProcessOrder = ProcessOrder; dbObj.ChildExpenditureCategory = ExpenditureCategory; } } }