コード例 #1
0
        public IActionResult PutCompany(int id, CompanyVM companyVM)
        {
            if (ModelState.IsValid)
            {
                if (id != companyVM.Id)
                {
                    return(BadRequest());
                }

                try
                {
                    _companyRepo.UpdateCompany(companyVM);
                    return(Ok());
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!_companyRepo.CompanyExists(id))
                    {
                        return(NotFound());
                    }
                }
                catch (KeyNotFoundException)
                {
                    return(NotFound());
                }
                catch (Exception e)
                {
                    return(StatusCode(500, new { status = 500, message = e.Message }));
                }

                return(NoContent());
            }
            return(BadRequest());
        }