72 lines
2.1 KiB
C#
72 lines
2.1 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel.DataAnnotations;
|
|
using System.Linq;
|
|
using System.Web;
|
|
using EnVisage.Code;
|
|
|
|
namespace EnVisage.Models
|
|
{
|
|
public class GLAccountModel : IBaseModel<GLAccount>
|
|
{
|
|
public Guid Id { get; set; }
|
|
|
|
[Required]
|
|
[MaxLength(100)]
|
|
[Display(Name="GL Account Name")]
|
|
public string Name { get; set; }
|
|
|
|
[Required]
|
|
[MaxLength(20)]
|
|
[Display(Name = "GL Account Number")]
|
|
public string GLNumber { get; set; }
|
|
[Display(Name = "Number of Expenditures")]
|
|
public int ExpenditureCount { get; set; }
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// Casts a <see cref="GLAccount"/> obect to the object of type <see cref="GLAccountModel"/>.
|
|
/// </summary>
|
|
/// <param name="obj">A <see cref="GLAccount"/> object.</param>
|
|
/// <returns>A <see cref="GLAccountModel"/> object filled with data from db.</returns>
|
|
public static explicit operator GLAccountModel(GLAccount obj)
|
|
{
|
|
if (obj == null)
|
|
return null;
|
|
var model = new GLAccountModel
|
|
{
|
|
Id = obj.Id,
|
|
Name = obj.Name,
|
|
GLNumber = obj.GLNumber,
|
|
ExpenditureCount = obj.ExpenditureCategories.Count
|
|
};
|
|
model.TrimStringProperties();
|
|
return model;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Copies data from model to DAL object.
|
|
/// </summary>
|
|
/// <param name="dbObj">A target DAL object.</param>
|
|
public void CopyTo(GLAccount dbObj)
|
|
{
|
|
if (dbObj == null)
|
|
throw new ArgumentNullException();
|
|
|
|
dbObj.Name = Name;
|
|
dbObj.GLNumber = GLNumber;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// An UI representation of client to be displayed as list items
|
|
/// </summary>
|
|
public class GLAccountListModel
|
|
{
|
|
public Guid Id { get; set; }
|
|
public string Name { get; set; }
|
|
public string GLNumber { get; set; }
|
|
public int ExpenditureCount { get; set; }
|
|
}
|
|
} |