public SalaryAllowanceModel() { // init entity _salaryDecision = new sal_SalaryDecision(); _basicSalary = new cat_BasicSalary(); _allowance = new cat_Allowance(); // set default props for model Init(new sal_SalaryAllowance()); }
public SalaryAllowanceModel(sal_SalaryAllowance entity) { // init entity entity = entity ?? new sal_SalaryAllowance(); _salaryDecision = sal_SalaryDecisionServices.GetById(entity.SalaryDecisionId) ?? new sal_SalaryDecision(); _basicSalary = cat_BasicSalaryServices.GetCurrent() ?? new cat_BasicSalary(); _allowance = cat_AllowanceServices.GetByCode(entity.AllowanceCode) ?? new cat_Allowance(); // set custom props AllowanceName = _allowance.Name; // set model props Init(entity); }
/// <summary> /// Update /// </summary> /// <param name="model"></param> /// <returns></returns> public static CatalogAllowanceModel Update(CatalogAllowanceModel model) { // get existed by name var existedEntity = GetByCode(model.Code); // check existed if (existedEntity == null || existedEntity.Id == model.Id) { // init new entity var entity = new cat_Allowance(); // set entity props model.FillEntity(ref entity); // update return(new CatalogAllowanceModel(cat_AllowanceServices.Update(entity))); } // invalid param return(null); }
/// <summary> /// Create /// </summary> /// <param name="model"></param> /// <returns></returns> public static CatalogAllowanceModel Create(CatalogAllowanceModel model) { // get existed by name var existedEntity = GetByCode(model.Code); // check existed if (existedEntity == null) { // init entity var entity = new cat_Allowance(); // get entity from db model.FillEntity(ref entity); // return return(new CatalogAllowanceModel(cat_AllowanceServices.Create(entity))); } // invalid param return(null); }