public IActionResult Put(CatUnitModel model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }
            var checkExistMessage = CheckExist(model.Id, model);

            if (checkExistMessage.Length > 0)
            {
                return(BadRequest(new ResultHandle {
                    Status = false, Message = checkExistMessage
                }));
            }
            var          hs      = catUnitService.Update(model);
            var          message = HandleError.GetMessage(hs, Crud.Update);
            ResultHandle result  = new ResultHandle {
                Status = hs.Success, Message = stringLocalizer[message].Value
            };

            if (!hs.Success)
            {
                return(BadRequest(result));
            }
            return(Ok(result));
        }
        private string CheckExist(int id, CatUnitModel model)
        {
            string message = string.Empty;

            if (id == 0)
            {
                if (catUnitService.Any(x => (x.Code.ToLower() == model.Code.ToLower()) || string.IsNullOrEmpty(model.Code)))
                {
                    message = stringLocalizer[LanguageSub.MSG_CODE_EXISTED].Value;
                }
                else if (catUnitService.Any(x => x.UnitNameEn.ToLower() == model.UnitNameEn.ToLower() || string.IsNullOrEmpty(model.UnitNameEn)))
                {
                    message = stringLocalizer[CatalogueLanguageSub.MSG_NAME_EN_EXISTED].Value;
                }
                else if (catUnitService.Any(x => x.UnitNameVn.ToLower() == model.UnitNameVn.ToLower() || string.IsNullOrEmpty(model.UnitNameVn)))
                {
                    message = stringLocalizer[CatalogueLanguageSub.MSG_NAME_LOCAL_EXISTED].Value;
                }
            }
            else
            {
                if (catUnitService.Any(x => (x.Code.ToLower() == model.Code.ToLower() && x.Id != id) || string.IsNullOrEmpty(model.Code)))
                {
                    message = stringLocalizer[LanguageSub.MSG_CODE_EXISTED].Value;
                }
                else if (catUnitService.Any(x => (x.UnitNameEn.ToLower() == model.UnitNameEn.ToLower() && x.Id != id) || string.IsNullOrEmpty(model.UnitNameEn)))
                {
                    message = stringLocalizer[CatalogueLanguageSub.MSG_NAME_EN_EXISTED].Value;
                }
                else if (catUnitService.Any(x => (x.UnitNameVn.ToLower() == model.UnitNameVn.ToLower() && x.Id != id) || string.IsNullOrEmpty(model.UnitNameVn)))
                {
                    message = stringLocalizer[CatalogueLanguageSub.MSG_NAME_LOCAL_EXISTED].Value;
                }
            }
            return(message);
        }