public ActionResult Edit(TimelineExhibit timelineexhibit) { if (!Authorization.GetAccess(table, HttpContext.User.Identity.Name, write)) { return(RedirectToAction("Index", "Home")); } if (ModelState.IsValid) { Exhibit exhibit = db.Exhibits.Where(e => e.ID == timelineexhibit.ExhibitID).FirstOrDefault(); Timeline timeline = db.Timelines.Where(t => t.ID == timelineexhibit.TimelineID).FirstOrDefault(); if (isValid(timeline, exhibit)) { timelineexhibit.ModifiedBy = Guid.Parse(Session["userid"].ToString()); timelineexhibit.ModifiedOn = DateTime.Now; db.TimelineExhibits.Attach(timelineexhibit); db.ObjectStateManager.ChangeObjectState(timelineexhibit, EntityState.Modified); db.SaveChanges(); return(RedirectToAction("Index")); } } ViewBag.ExhibitID = new SelectList(db.Exhibits.Where(r => r.IsDeleted == null || r.IsDeleted == false).OrderByDescending(e => e.CreatedOn), "ID", "Title", timelineexhibit.ExhibitID); ViewBag.TimelineID = new SelectList(db.Timelines.Where(r => r.IsDeleted == null || r.IsDeleted == false).OrderBy(t => t.Title), "ID", "Title", timelineexhibit.TimelineID); ViewBag.CreatedBy = new SelectList(db.Users, "ID", "UserName", timelineexhibit.CreatedBy); ViewBag.ModifiedBy = new SelectList(db.Users, "ID", "UserName", timelineexhibit.ModifiedBy); return(View(timelineexhibit)); }
// // GET: /TimelineExhibit/Details/5 public ActionResult Details(Guid id) { if (!Authorization.GetAccess(table, HttpContext.User.Identity.Name, read)) { return(RedirectToAction("Index", "Home")); } TimelineExhibit timelineexhibit = db.TimelineExhibits.Single(t => t.TimelineExhibitID == id && (t.IsDeleted == null || t.IsDeleted == false)); return(View(timelineexhibit)); }
// // GET: /TimelineExhibit/Edit/5 public ActionResult Edit(Guid id) { if (!Authorization.GetAccess(table, HttpContext.User.Identity.Name, write)) { return(RedirectToAction("Index", "Home")); } TimelineExhibit timelineexhibit = db.TimelineExhibits.Single(t => t.TimelineExhibitID == id && (t.IsDeleted == null || t.IsDeleted == false)); ViewBag.ExhibitID = new SelectList(db.Exhibits.Where(r => r.IsDeleted == null || r.IsDeleted == false).OrderByDescending(e => e.CreatedOn), "ID", "Title", timelineexhibit.ExhibitID); ViewBag.TimelineID = new SelectList(db.Timelines.Where(r => r.IsDeleted == null || r.IsDeleted == false).OrderBy(t => t.Title), "ID", "Title", timelineexhibit.TimelineID); ViewBag.CreatedBy = new SelectList(db.Users, "ID", "UserName", timelineexhibit.CreatedBy); ViewBag.ModifiedBy = new SelectList(db.Users, "ID", "UserName", timelineexhibit.ModifiedBy); return(View(timelineexhibit)); }
public ActionResult DeleteConfirmed(Guid id) { if (!Authorization.GetAccess(table, HttpContext.User.Identity.Name, delete)) { return(RedirectToAction("Index", "Home")); } TimelineExhibit timelineexhibit = db.TimelineExhibits.Single(t => t.TimelineExhibitID == id && (t.IsDeleted == null || t.IsDeleted == false)); timelineexhibit.ModifiedBy = Guid.Parse(Session["userid"].ToString()); timelineexhibit.ModifiedOn = DateTime.Now; timelineexhibit.IsDeleted = true; db.ObjectStateManager.ChangeObjectState(timelineexhibit, EntityState.Modified); //db.TimelineExhibits.DeleteObject(timelineexhibit); db.SaveChanges(); return(RedirectToAction("Index")); }