using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.Linq; using System.Web; namespace EnVisage.Models { public class FeeCalculationModel { public System.Guid Id { get; set; } public System.Guid ExpenditureCategoryId { get; set; } [Required] [Display(Name = "Minimum Shot")] public int MinShot { get; set; } [Required] [Display(Name = "Maximum Shot")] public int MaxShot { get; set; } [Required] [Display(Name = "Quantity")] public int Quantity { 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 FeeCalculationModel(FeeCalculation obj) { if (obj == null) return null; var model = new FeeCalculationModel { Id = obj.Id, ExpenditureCategoryId = obj.ExpenditureCategoryId, MinShot = obj.MinShot, MaxShot = obj.MaxShot, Quantity = obj.Quantity, ExpenditureCategory = obj.ExpenditureCategory }; return model; } /// /// Copies data from model to DAL object. /// /// A target DAL object. public void CopyTo(FeeCalculation dbObj) { if (dbObj == null) throw new ArgumentNullException(); dbObj.ExpenditureCategoryId = ExpenditureCategoryId; dbObj.MinShot = MinShot; dbObj.MaxShot = MaxShot; dbObj.Quantity = Quantity; dbObj.ExpenditureCategory = ExpenditureCategory; } } }