public IHttpActionResult Put(int id, [FromBody] MajorDto form) { if (ModelState.IsValid) { var majorInDb = _majorService.Get(id); if (majorInDb == null) { return(NotFound()); } try { Mapper.Map(form, majorInDb); _majorService.Update(majorInDb); return(Ok()); } catch (ForeignKeyEntityException fkee) { ModelState.AddModelError("", fkee.Message); } } return(BadRequest(ModelState)); }
public IActionResult Put(int id, [FromBody] Major major) { majorService.Update(major); return(Ok()); }