/// <summary> /// This action retrieves the details of an usher assignment /// </summary> /// <param name="id">Usher appointed id</param> /// <returns>Details view</returns> // GET: UsherAppointed/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } UsherAppointed usherAppointed = db.UsherAppointeds.Find(id); if (usherAppointed == null) { return(HttpNotFound()); } var model = new UsherAppointedViewModel { UsherAppointedId = usherAppointed.UsherAppointedId, DateAppointed = usherAppointed.DateAppointed, Usher = usherAppointed.Usher.FullName, EventProject = usherAppointed.EventProject.Name, Employee = usherAppointed.Employee.FullName, }; return(View(model)); }
/// <summary> /// This action retrieves the deletion page /// </summary> /// <param name="id">Usher appointed id</param> /// <returns>Delete view or error view</returns> // GET: UsherAppointed/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } UsherAppointed usherAppointed = db.UsherAppointeds.Find(id); if (usherAppointed == null) { return(HttpNotFound()); } UsherAppointedViewModel model = new UsherAppointedViewModel { EventProjectId = usherAppointed.EventProjectId, DateAppointed = usherAppointed.DateAppointed, Usher = usherAppointed.Usher.FullName, EventProject = usherAppointed.EventProject.Name, Employee = usherAppointed.Employee.FullName, }; ViewBag.UsherId = new SelectList(db.Ushers, "UsherId", "FullName"); ViewBag.ProductionEmployeeId = new SelectList(db.Employees, "Id", "FullName"); ViewBag.EventProjectId = new SelectList(db.EventProjects, "EventProjectId", "Name"); return(View(model)); }
public ActionResult DeleteConfirmed(int id) { UsherAppointed usherAppointed = db.UsherAppointeds.Find(id); db.UsherAppointeds.Remove(usherAppointed); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Create(UsherAppointedViewModel model) { if (ModelState.IsValid) { //var project = db.EventProjects.Find(model.EventProjectId); //if (project == null) //{ // return HttpNotFound(); //} var usherAppointed = new UsherAppointed { DateAppointed = DateTime.Now, UsherId = model.UsherId, EventProjectId = model.EventProjectId, ProductionEmployeeId = User.Identity.GetUserId <int>(), }; db.UsherAppointeds.Add(usherAppointed); db.SaveChanges(); ViewBag.UsherId = new SelectList(db.Ushers, "UsherId", "FullName"); ViewBag.ProductionEmployeeId = new SelectList(db.Employees, "Id", "FullName"); ViewBag.EventProjectId = new SelectList(db.EventProjects, "EventProjectId", "Name"); return(RedirectToAction("Index")); //return RedirectToAction("Details", new { id = usherAppointed.UsherAppointedId }); } else { ViewBag.UsherId = new SelectList(db.Ushers, "UsherId", "FullName"); ViewBag.ProductionEmployeeId = new SelectList(db.Employees, "Id", "FullName"); ViewBag.EventProjectId = new SelectList(db.EventProjects, "EventProjectId", "Name"); return(View()); } }