public IActionResult Update([FromBody] RealizationItem realizationItem) { if (realizationItem == null) { return(BadRequest()); } _context.Update(realizationItem); _context.SaveChanges(); return(CreatedAtRoute("GetRealizationItem", new { id = realizationItem.Id }, realizationItem)); }
public IActionResult Update([FromBody] Category category) { if (category == null) { return(BadRequest()); } var dbCategory = _context.Categories.Find(category.Id); if (dbCategory == null) { return(NotFound()); } dbCategory.Name = category.Name; _context.Update(dbCategory); _context.SaveChanges(); return(CreatedAtRoute("GetCategory", new { id = category.Id }, category)); }
public IActionResult Update([FromBody] Objective objective) { if (objective == null) { return(BadRequest()); } if (!_context.Objectives.Contains(objective)) { return(NotFound()); } _context.Entry(objective.Category).State = _context.Categories.Contains(objective.Category) ? EntityState.Modified : EntityState.Added; _context.Update(objective); _context.SaveChanges(); return(CreatedAtRoute("GetObjective", new { id = objective.Id }, objective)); }