public async Task <IActionResult> PutConstituencyDetails(long id, ConstituencyDetails constituencyDetails) { if (id != constituencyDetails.ConstituencyDetailId) { return(BadRequest()); } db.Entry(constituencyDetails).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ConstituencyDetailsExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public ActionResult DeveloperEdit(CandidatesModel model) { try { if (ModelState.IsValid) { db.Entry(model.Candidates).State = EntityState.Modified; db.Entry(model.OccupationArea).State = EntityState.Modified; db.Entry(model.InformationBank).State = EntityState.Modified; db.Entry(model.Knowledge).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Developer", "Homeoffice")); } } catch (DbUpdateConcurrencyException ex) { // Update the values of the entity that failed to save from the store ex.Entries.Single().Reload(); } return(View(model)); }