コード例 #1
0
        public IActionResult Add(SysCompanyAddModel company)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }
            var checkExistMessage = CheckExist(company);

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

            var message = HandleError.GetMessage(hs, Crud.Insert);

            ResultHandle result = new ResultHandle {
                Status = hs.Success, Message = stringLocalizer[message].Value, Data = company
            };

            if (!hs.Success)
            {
                return(BadRequest(result));
            }
            return(Ok(result));
        }