示例#1
0
        public ActionResult <EnterpriseModel> CreateEnterprise([FromBody] EnterpriseModel enterprise)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(BadRequest(ModelState));
                }

                var newEnterprise = service.CreateEnterprise(enterprise);
                return(Created($"/api/Enterprises/{newEnterprise.Id}", newEnterprise));
            }
            catch (NotFoundException ex)
            {
                return(NotFound(ex.Message));
            }
            catch (Exception ex)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError, ex.Message));;
            }
        }