Esempio n. 1
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);
        }
Esempio n. 2
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);
        }