Пример #1
0
 // GET: Admin/Types/Details/5
 public ActionResult Details(Guid?id)
 {
     if (id == null)
     {
         return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
     }
     GameCLGT.Areas.Admin.Models.Type type = db.Types.Find(id);
     if (type == null)
     {
         return(HttpNotFound());
     }
     return(View(type));
 }
Пример #2
0
 // GET: Admin/Types/Edit/5
 public ActionResult Edit(Guid?id)
 {
     if (id == null)
     {
         return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
     }
     GameCLGT.Areas.Admin.Models.Type type = db.Types.Find(id);
     if (type == null)
     {
         return(HttpNotFound());
     }
     ViewBag.ID = new SelectList(db.List_type_game, "ID", "ID_game", type.ID);
     return(View(type));
 }
Пример #3
0
 public ActionResult Edit([Bind(Include = "ID,Type_name,Type_image")] GameCLGT.Areas.Admin.Models.Type type, HttpPostedFileBase file)
 {
     if (file != null)
     {
         var fileName = Path.GetFileName(file.FileName);
         var filePath = Path.Combine(Server.MapPath("~/Content/Images/Types/"), fileName);
         file.SaveAs(filePath);
         type.Type_image = "/Content/Images/Types/" + file.FileName;
     }
     if (ModelState.IsValid)
     {
         db.Entry(type).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.ID = new SelectList(db.List_type_game, "ID", "ID_game", type.ID);
     return(View(type));
 }
Пример #4
0
        public ActionResult DeleteConfirmed(Guid id)
        {
            GameCLGT.Areas.Admin.Models.Type type = db.Types.Find(id);

            var fileName = type.Type_image;
            var filePath = Server.MapPath(fileName);

            System.IO.File.Delete(filePath);

            List <List_type_game> lstType = new List <List_type_game>();

            foreach (var item in lstType)
            {
                db.List_type_game.Remove(item);
            }

            db.Types.Remove(type);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Пример #5
0
        public ActionResult Create([Bind(Include = "ID,Type_name,Type_image")] GameCLGT.Areas.Admin.Models.Type type, HttpPostedFileBase file)
        {
            if (file != null)
            {
                string img  = Path.GetFileName(file.FileName);
                string path = Path.Combine(Server.MapPath("~/Content/Images/Types"), img);
                file.SaveAs(path);
                type.Type_image = "/Content/Images/Types/" + file.FileName;
            }

            if (ModelState.IsValid)
            {
                type.ID = Guid.NewGuid();
                db.Types.Add(type);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.ID = new SelectList(db.List_type_game, "ID", "ID_game", type.ID);
            return(View(type));
        }