Exemplo n.º 1
0
        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());
        }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
        /// <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);
        }
Exemplo n.º 4
0
        /// <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);
        }