88 lines
2.6 KiB
C#
88 lines
2.6 KiB
C#
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<FactorTypes> FactorType { get; set; }
|
|
[Required]
|
|
[Display(Name = "Factor")]
|
|
public Nullable<decimal> FactorInt { get; set; }
|
|
[Required]
|
|
[Display(Name = "Process Order")]
|
|
public Nullable<int> ProcessOrder { get; set; }
|
|
|
|
public virtual ExpenditureCategory ExpenditureCategory { get; set; }
|
|
|
|
/// <summary>
|
|
/// Casts a <see cref="Expenditure2Expenditure"/> obect to the object of type <see cref="RateModel"/>.
|
|
/// </summary>
|
|
/// <param name="obj">A <see cref="Expenditure2Expenditure"/> object.</param>
|
|
/// <returns>A <see cref="RateModel"/> object filled with data from db.</returns>
|
|
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;
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// Copies data from model to DAL object.
|
|
/// </summary>
|
|
/// <param name="dbObj">A target DAL object.</param>
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
}
|
|
} |