public ActionResult DeleteConfirmed(int id) { ReportUserModel reportUserModel = db.ReportUserModels.Find(id); db.ReportUserModels.Remove(reportUserModel); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } ReportUserModel reportUserModel = db.ReportUserModels.Find(id); if (reportUserModel == null) { return(HttpNotFound()); } ReportUserViewModel vm = new ReportUserViewModel(); vm.reportUser = reportUserModel; vm.lsUser = Utility.GetUsers(); vm.lsReports = Utility.GetReports(); return(View(vm)); }
private void AddReportsForUser(string sUserName, List <string> lsReportIDs) { List <ReportUserModel> ls = new List <ReportUserModel>(); foreach (string s in lsReportIDs) { ReportUserModel rum = new ReportUserModel(); rum.username = sUserName; rum.ReportID = Convert.ToInt32(s); rum.isActive = true; rum.ts = DateTime.Now; ls.Add(rum); } foreach (ReportUserModel r in ls) { if (!db.ReportUserModels.Where(x => x.username == r.username && x.ReportID == r.ReportID).Any()) { db.ReportUserModels.Add(r); db.SaveChanges(); } } }