public IHttpActionResult Update(int id, TeamDto teamDto) { if (!ModelState.IsValid) { return(BadRequest()); } var teamInDb = _context.Teams.SingleOrDefault(c => c.Id == id); if (teamInDb == null) { return(NotFound()); } _factory.MapFromDtoToTeam(teamDto, teamInDb); _context.SaveChanges(); return(Ok(teamDto)); }
public ActionResult Save(TeamDto team) { if (!ModelState.IsValid) { return(View("TeamForm", team)); } var dbTeam = _context.Teams.SingleOrDefault(t => t.Id == team.Id); if (dbTeam == null) { return(HttpNotFound()); } _factory.MapFromDtoToTeam(team, dbTeam); _context.SaveChanges(); return(RedirectToAction("Index")); }