Example #1
0
        public ActionResult <CommonResponeModel> SaveChangeContact(EmployeeContactDetailRequestModel model)
        {
            var databaseObject = new Employee();
            int result;

            if (model.Id == 0)
            {
                Result = new ErrorResult(ActionType.Insert, CommonMessageGlobal.NotExist("Mã nhân viên"));
                return(GetCommonRespone());
            }
            else
            {
                databaseObject = employeeRepository.GetById(model.Id);
                databaseObject.MapFrom(model);
                databaseObject.InitBeforeSave(RequestUsername, InitType.Update);
                databaseObject.InitDefault();

                result = employeeRepository.Update(databaseObject);
            }

            if (result > 0)
            {
                Result = new SuccessResult(ActionType.Edit, AppGlobal.SaveChangeSuccess);
            }
            else
            {
                Result = new ErrorResult(ActionType.Edit, AppGlobal.SaveChangeFalse);
            }

            return(GetCommonRespone());
        }