78 lines
2.6 KiB
C#
78 lines
2.6 KiB
C#
using System;
|
|
using System.ComponentModel.DataAnnotations;
|
|
|
|
namespace EnVisage.Models
|
|
{
|
|
public class RateModel : IBaseModel<Rate>
|
|
{
|
|
#region enums and subclasses
|
|
public enum RateType
|
|
{
|
|
Global = 0,
|
|
Derived = 1
|
|
}
|
|
#endregion
|
|
|
|
public Guid Id { get; set; }
|
|
public Guid? ParentId { get; set; }
|
|
public Guid ExpenditureCategoryId { get; set; }
|
|
public RateType Type { get; set; }
|
|
[Required]
|
|
[Display(Name = "Rate")]
|
|
public decimal Rate1 { get; set; }
|
|
[Display(Name = "Start Date")]
|
|
[DataType(DataType.Date), DisplayFormat(DataFormatString = "{0:MM/dd/yy}", ApplyFormatInEditMode = true)]
|
|
public DateTime StartDate { get; set; }
|
|
[Display(Name = "End Date")]
|
|
[DataType(DataType.Date), DisplayFormat(DataFormatString = "{0:MM/dd/yy}", ApplyFormatInEditMode = true)]
|
|
public DateTime EndDate { get; set; }
|
|
public Guid? DerivedObjectId { get; set; }
|
|
public int FreezeRate { get; set; }
|
|
|
|
//public virtual ExpenditureCategory ExpenditureCategory { get; set; }
|
|
|
|
|
|
/// <summary>
|
|
/// Casts a <see cref="Rate"/> obect to the object of type <see cref="RateModel"/>.
|
|
/// </summary>
|
|
/// <param name="obj">A <see cref="Rate"/> object.</param>
|
|
/// <returns>A <see cref="RateModel"/> object filled with data from db.</returns>
|
|
public static explicit operator RateModel(Rate obj)
|
|
{
|
|
if (obj == null)
|
|
return null;
|
|
var model = new RateModel
|
|
{
|
|
Id = obj.Id,
|
|
ParentId = obj.ParentId,
|
|
ExpenditureCategoryId = obj.ExpenditureCategoryId,
|
|
Type = (RateType)obj.Type,
|
|
Rate1 = obj.Rate1,
|
|
StartDate = obj.StartDate,
|
|
EndDate = obj.EndDate,
|
|
DerivedObjectId = obj.DerivedId,
|
|
FreezeRate = obj.FreezeRate,
|
|
};
|
|
return model;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Copies data from model to DAL object.
|
|
/// </summary>
|
|
/// <param name="dbObj">A target DAL object.</param>
|
|
public void CopyTo(Rate dbObj)
|
|
{
|
|
if (dbObj == null)
|
|
throw new ArgumentNullException();
|
|
dbObj.ParentId = ParentId;
|
|
dbObj.ExpenditureCategoryId = ExpenditureCategoryId;
|
|
dbObj.Type = (short)Type;
|
|
dbObj.Rate1 = Rate1;
|
|
dbObj.StartDate = StartDate;
|
|
dbObj.EndDate = EndDate;
|
|
dbObj.DerivedId = DerivedObjectId;
|
|
dbObj.FreezeRate = FreezeRate;
|
|
}
|
|
|
|
}
|
|
} |