Esempio n. 1
0
        public IActionResult CreateCase([FromBody] Case _case)
        {
            if (_case == null)
            {
                return(BadRequest());
            }

            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }

            if (!_caseRepository.CreateCase(_case))
            {
                ModelState.AddModelError("", $"Something went wrong saving {_case.FirstName} info");
                return(StatusCode(500, ModelState));
            }

            return(CreatedAtRoute("GetCase", new { caseId = _case.id }, _case));
        }
Esempio n. 2
0
        public IActionResult CreateCase([FromBody] Case data)
        {
            if (data == null)
            {
                return(BadRequest(ModelState));
            }

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (!_caseRepository.CreateCase(data))
            {
                ModelState.AddModelError("", $"Something went wrong saving the case " +
                                         $"{data.FirstName} {data.LastName}");
                return(StatusCode(500, ModelState));
            }

            return(CreatedAtRoute("GetCase", new { caseId = data.Id }, data));
        }