public ActionResult Create([Bind(Include = "Id,Name,FireStationId")] BreakRoom breakRoom, IEnumerable <HttpPostedFileBase> image) { if (ModelState.IsValid) { foreach (var item in image) { string error; if (!FileHelper.CheckIfFileIsImage(item, out error)) { ModelState.AddModelError("", error); ViewBag.FireStationId = new SelectList(DataFilter.GetFireStations(TempData.Peek("Id") + ""), "Id", "Name", breakRoom.FireStationId); return(View(breakRoom)); } } breakRoom.Id = Guid.NewGuid(); string basePath = Server.MapPath(Constants.BREAK_ROOM_UPLOAD_BASE_PATH + breakRoom.Id + "/"); FileHelper.SaveFiles(image, basePath); db.BreakRooms.Add(breakRoom); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.FireStationId = new SelectList(DataFilter.GetFireStations(TempData.Peek("Id") + ""), "Id", "Name", breakRoom.FireStationId); return(View(breakRoom)); }
public ActionResult DeleteConfirmed(Guid id) { BreakRoom breakRoom = db.BreakRooms.Find(id); db.BreakRooms.Remove(breakRoom); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "Id,Name,FireStationId")] BreakRoom breakRoom) { if (ModelState.IsValid) { db.Entry(breakRoom).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.FireStationId = new SelectList(DataFilter.GetFireStations(TempData.Peek("Id") + ""), "Id", "Name", breakRoom.FireStationId); return(View(breakRoom)); }
private static void Main(string[] args) { IMediator breakRoom = new BreakRoom(); var workers = new List<IWorker> { new CharismaticWorker(breakRoom), new SimpleWorker(breakRoom), new SimpleWorker(breakRoom) }; workers[0].PromoteToRiot(); Console.ReadKey(); }
// GET: BreakRooms/Delete/5 public ActionResult Delete(Guid?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } BreakRoom breakRoom = db.BreakRooms.Find(id); if (breakRoom == null) { return(HttpNotFound()); } return(View(breakRoom)); }
// GET: BreakRooms/Edit/5 public ActionResult Edit(Guid?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } BreakRoom breakRoom = db.BreakRooms.Find(id); if (breakRoom == null) { return(HttpNotFound()); } ViewBag.FireStationId = new SelectList(DataFilter.GetFireStations(TempData.Peek("Id") + ""), "Id", "Name", breakRoom.FireStationId); return(View(breakRoom)); }
// GET: BreakRooms/Details/5 public ActionResult Details(Guid?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } BreakRoom breakRoom = db.BreakRooms.Find(id); string basePath = Server.MapPath(Constants.BREAK_ROOM_UPLOAD_BASE_PATH + breakRoom.Id + "/"); if (Directory.Exists(basePath)) { TempData["Images"] = FileHelper.GetImages(breakRoom.Id + "", basePath); } if (breakRoom == null) { return(HttpNotFound()); } return(View(breakRoom)); }