Exemplo n.º 1
0
        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));
        }
Exemplo n.º 2
0
        public ActionResult DeleteConfirmed(Guid id)
        {
            BreakRoom breakRoom = db.BreakRooms.Find(id);

            db.BreakRooms.Remove(breakRoom);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Exemplo n.º 3
0
 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));
 }
Exemplo n.º 4
0
 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();
 }
Exemplo n.º 5
0
        // 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));
        }
Exemplo n.º 6
0
        // 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));
        }
Exemplo n.º 7
0
        // 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));
        }