public IHttpActionResult Put(int?id, [FromBody] WorkDto work) { try { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id == null || id <= 0) { return(BadRequest()); } var dbWork = workService.GetByID((int)id); if (dbWork == null) { return(NotFound()); } dbWork.ComposerID = work.ComposerID; dbWork.Title = work.Title; dbWork.EraID = work.EraID; dbWork.Description = work.Description; dbWork.Year = work.Year; workService.Update(dbWork); workService.Save(); return(StatusCode(HttpStatusCode.NoContent)); } catch (Exception ex) { return(BadRequest(ex.Message)); } }
public IActionResult Update(WorkMD metaData) { var result = _service.Update(metaData); if (!result.Status) { ViewBag.ErrorMessage = result.Message; return(View(result.Data)); } return(RedirectToAction("Index", "Work")); }