Пример #1
0
        public IActionResult Update(CatCountryModel catCountry)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }
            var checkExistMessage = CheckExist(catCountry.Id, catCountry);

            if (checkExistMessage.Length > 0)
            {
                return(BadRequest(new ResultHandle {
                    Status = false, Message = checkExistMessage
                }));
            }

            var          hs      = catCountryService.Update(catCountry);
            var          message = HandleError.GetMessage(hs, Crud.Update);
            ResultHandle result  = new ResultHandle {
                Status = hs.Success, Message = stringLocalizer[message].Value
            };

            if (!hs.Success)
            {
                return(BadRequest(result));
            }
            catCountryService.ClearCache();
            return(Ok(result));
        }
Пример #2
0
        /// <summary>
        /// Tạo mời một CatCountry
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public ActionResult Create([Bind] CatCountryModel model)
        {
            var service = new RestServiceClient <CatCountryModel>(UserLogin);

            service.SetCookies(this.Request.Cookies, _hrm_Hre_Service);
            var result = service.Put(_hrm_Hre_Service, "api/CatCountry/", model);

            return(Json(result));
        }
Пример #3
0
 public CatCountryModel Post([Bind] CatCountryModel model)
 {
     #region Validate
     string message       = string.Empty;
     var    checkValidate = HRM.Business.Main.Domain.ValidatorService.OnValidateData <CatCountryModel>(model, "Cat_Country", ref message);
     if (!checkValidate)
     {
         model.ActionStatus = message;
         return(model);
     }
     #endregion
     ActionService service = new ActionService(UserLogin);
     return(service.UpdateOrCreate <Cat_CountryEntity, CatCountryModel>(model));
 }
Пример #4
0
        /// <summary>
        /// [Tin.Nguyen] - Lấy dữ liệu Quốc Gia(Cat_Country) theo Id
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public CatCountryModel GetById(Guid id)
        {
            string        status  = string.Empty;
            var           model   = new CatCountryModel();
            ActionService service = new ActionService(UserLogin);
            var           entity  = service.GetByIdUseStore <Cat_CountryEntity>(id, ConstantSql.hrm_cat_sp_get_CountrybyId, ref status);

            if (entity != null)
            {
                model = entity.CopyData <CatCountryModel>();
            }
            model.ActionStatus = status;
            return(model);
        }
Пример #5
0
        private string CheckExist(int id, CatCountryModel model)
        {
            string message = string.Empty;

            if (id == 0)
            {
                if (catCountryService.Any(x => x.Code.ToLower() == model.Code.ToLower()))
                {
                    message = stringLocalizer[LanguageSub.MSG_CODE_EXISTED].Value;
                }
            }
            else
            {
                if (catCountryService.Any(x => x.Code.ToLower() == model.Code.ToLower() && x.Id != id))
                {
                    message = stringLocalizer[LanguageSub.MSG_CODE_EXISTED].Value;
                }
            }
            return(message);
        }