public ActionResult DeleteConfirmed(int id) { AcctReport acctReport = db.AcctReports.Find(id); db.AcctReports.Remove(acctReport); db.SaveChanges(); return(RedirectToAction("Index")); }
// GET: Directories/AcctReportsTest/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } AcctReport acctReport = db.AcctReports.Find(id); if (acctReport == null) { return(HttpNotFound()); } return(View(acctReport)); }
// GET: Directories/AcctReportsTest/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } AcctReport acctReport = db.AcctReports.Find(id); if (acctReport == null) { return(HttpNotFound()); } ViewBag.ClientTypes = db.ClientTypes.ToList(); return(View(acctReport)); }
public ActionResult Create([Bind(Include = "Id,Acc2,Resident,CntrPartner")] AcctReport acctReport, int[] selectedClientTypes) { if (ModelState.IsValid) { if (selectedClientTypes != null) { foreach (var c in db.ClientTypes.Where(co => selectedClientTypes.Contains(co.Id))) { acctReport.ClientTypes.Add(c); } } db.AcctReports.Add(acctReport); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(acctReport)); }
public ActionResult Edit([Bind(Include = "Id,Acc2,Resident,CntrPartner, selectedClientTypes")] AcctReport acctReport, int[] selectedClientTypes) { if (ModelState.IsValid) { AcctReport acctReportUpdated = db.AcctReports.Find(acctReport.Id); UpdateModel(acctReportUpdated); acctReportUpdated.ClientTypes.Clear(); if (selectedClientTypes != null) { foreach (var c in db.ClientTypes.Where(co => selectedClientTypes.Contains(co.Id))) { acctReportUpdated.ClientTypes.Add(c); } } db.Entry(acctReportUpdated).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(acctReport)); }