public ActionResult Create([Bind(Include = "EventID,Description")] CateringService cateringService) { try { if (ModelState.IsValid) { db.CateringServices.Add(cateringService); db.SaveChanges(); return(RedirectToAction("Index")); } } catch (DataException dex) { if (dex.InnerException.InnerException.Message.Contains("IX_")) { ModelState.AddModelError("Name", "Unable to save changes. Remember, you cannot upload the same file twice or another file using the same file name."); } else { ModelState.AddModelError("", "Unable to save changes. Try again, and if the problem persists see your system administrator."); } } ViewBag.EventID = new SelectList(db.Events, "ID", "Name", cateringService.EventID); return(View(cateringService)); }
public ActionResult Edit([Bind(Include = "EventID,Description")] CateringService cateringService) { try { if (ModelState.IsValid) { db.Entry(cateringService).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } } catch (DataException dex) { if (dex.InnerException.InnerException.Message.Contains("IX_")) { ModelState.AddModelError("Name", "Unable to save changes due to constraint."); } else { ModelState.AddModelError("", "Unable to save changes. Try again, and if the problem persists see your system administrator."); } } ViewBag.EventID = new SelectList(db.Events, "ID", "Name", cateringService.EventID); return(View(cateringService)); }
//GET: Delete/Catering public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } CateringService cateringService = db.CateringServices.Find(id); if (cateringService == null) { return(HttpNotFound()); } return(View(cateringService)); }
// GET: CateringServices/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } CateringService cateringService = db.CateringServices.Where(s => s.EventID == id).SingleOrDefault(); if (cateringService == null) { return(HttpNotFound()); } return(View(cateringService)); }
//GET: Edit/Catering public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } CateringService cateringService = db.CateringServices.Find(id); if (cateringService == null) { return(HttpNotFound()); } PopulateDropDownList(cateringService); return(View(cateringService)); }
// GET: CateringServices/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } CateringService cateringService = db.CateringServices.Where(s => s.EventID == id).SingleOrDefault(); if (cateringService == null) { return(HttpNotFound()); } ViewBag.EventID = new SelectList(db.Events, "ID", "Name", cateringService.EventID); return(View(cateringService)); }
public ActionResult DeleteConfirmed(int id) { CateringService cateringService = db.CateringServices.Where(s => s.EventID == id).SingleOrDefault(); try { db.CateringServices.Remove(cateringService); db.SaveChanges(); return(RedirectToAction("Index")); } catch (DataException) { ModelState.AddModelError("", "Unable to delete schedule. Try again, and if the problem persists see your system administrator."); } return(View(cateringService)); }
public ActionResult Create([Bind(Include = "EventID, Name, Time")] CateringService cateringService) { try { if (ModelState.IsValid) { db.CateringServices.Add(cateringService); db.SaveChanges(); return(RedirectToAction("Index")); } } catch (DataException) { ModelState.AddModelError("", "Unable to save changes. Try again, and if the problem persists see your system administrator."); } PopulateDropDownList(cateringService); return(View(cateringService)); }
public IActionResult update(int id, CateringModel room) { CateringService service = new CateringService(); var status = true; bool result = false; try{ result = service.update(room, id); }catch (System.Exception) { status = false; } var rtn = new { status = status, result = result }; return(Ok(rtn)); }
public IActionResult get(int id) { CateringService service = new CateringService(); var status = true; CateringModel result = null; try{ result = service.get(id); }catch (System.Exception) { status = false; } var rtn = new { status = status, result = result }; return(Ok(rtn)); }
public IActionResult all() { CateringService service = new CateringService(); var status = true; List <CateringModel> result = null; try{ result = service.all(); }catch (System.Exception) { status = false; } var rtn = new { status = status, result = result }; return(Ok(rtn)); }
public ActionResult DeleteConfirmed(int id) { CateringService cateringService = db.CateringServices.Find(id); try { db.CateringServices.Remove(cateringService); db.SaveChanges(); return(RedirectToAction("Index")); } catch (DataException dex) { if (dex.InnerException.InnerException.Message.Contains("FK_")) { ModelState.AddModelError("", "Unable to delete catering service. You cannot delete a catering service that has an event in the system."); } else { ModelState.AddModelError("", "Unable to delete catering service. Try again, and if the problem persists see your system adminstrator."); } } return(View(cateringService)); }
private void PopulateDropDownList(CateringService cateringService = null) { ViewBag.EventID = new SelectList(db.Events .OrderBy(a => a.ID) .ThenBy(a => a.Name), "ID", "Name", cateringService?.EventID); }
public PartyPlannerFacade() { _cateringService = new CateringService(); _eventSpaceBooker = new EventSpaceBooker(); _invitationSender = new InvitationSender(); }