public ActionResult Create(ArchiveDocument archiveDocument) { using (var context = new DatabaseContext()) { if (!ModelState.IsValid) return View(CreateTuple(context, archiveDocument)); try { context.Entry(archiveDocument).State = EntityState.Added; context.SaveChanges(); return RedirectToAction("WithArchiveDocuments", "Client", new { id = archiveDocument.ClientId }); } catch { return View(CreateTuple(context, archiveDocument)); } } }
public ActionResult Edit(TextMessage textMessage) { using (var context = new DatabaseContext()) { if (!ModelState.IsValid) return View(CreateTuple(context, textMessage)); try { context.Entry(textMessage).State = EntityState.Modified; context.SaveChanges(); return RedirectToAction("WithTextMessages", "Client", new { id = textMessage.ClientId }); } catch { return View(CreateTuple(context, textMessage)); } } }
public ActionResult Edit([Bind(Prefix = "Item2")] Client client) { using (var context = new DatabaseContext()) { if (!ModelState.IsValid) return View( new Tuple<IEnumerable<Manager>, Client>(context.Managers.ToList(), client)); try { context.Entry(client).State = EntityState.Modified; context.SaveChanges(); return RedirectToAction("WithContacts", new { id = client.Id }); } catch { return View( new Tuple<IEnumerable<Manager>, Client>(context.Managers.ToList(), client)); } } }
public ActionResult Edit(IdentityDocument identityDocument) { using (var context = new DatabaseContext()) { if (!ModelState.IsValid) return View(CreateTuple(context, identityDocument)); try { context.Entry(identityDocument).State = EntityState.Modified; context.SaveChanges(); return RedirectToAction("WithIdentityDocuments", "Client", new { id = identityDocument.ClientId }); } catch { return View(CreateTuple(context, identityDocument)); } } }