Esempio n. 1
0
        public ActionResult DeleteConfirmed(int id)
        {
            MinLoLChampion minLoLChampion = db.MinLoLChampions.Find(id);

            db.MinLoLChampions.Remove(minLoLChampion);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Esempio n. 2
0
        public ActionResult Create([Bind(Include = "Name,Title,ChampIcon,ChampPic,ChampBio,ChampID,UltimateID,ChampRoleID")] MinLoLChampion minLoLChampion,
                                   IEnumerable <HttpPostedFileBase> files)
        {
            if (ModelState.IsValid)
            {
                //empty strings
                string icon       = "";
                string background = "";

                //get image file names
                foreach (var file in files)
                {
                    if (file != null)
                    {  //use the name to get the extension
                        string extcheck = file.FileName;
                        string ext      = extcheck.Substring(extcheck.LastIndexOf('.'));
                        //black list malicious code
                        if (ext == ".exe" || ext == ".dll")
                        {
                            //could set the photoUrl to null before returning

                            //sends to the view before persisting to the structure
                            return(View(minLoLChampion));
                        }
                        if (ext == ".png")
                        {
                            icon = minLoLChampion.Name + ext;
                            file.SaveAs(Server.MapPath("~/Content/Champions/Icons/" + icon));
                        }
                        else if (ext == ".jpg")
                        {
                            background = minLoLChampion.Name + ext;
                            file.SaveAs(Server.MapPath("~/Content/Champions/Pics/" + background));
                        }
                    }
                }



                ////add img values to champ object



                minLoLChampion.ChampIcon = icon;
                minLoLChampion.ChampPic  = background;
                db.MinLoLChampions.Add(minLoLChampion);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.ChampRoleID = new SelectList(db.MinLoLRoles, "ChampRoleID", "RoleName", minLoLChampion.ChampRoleID);
            ViewBag.UltimateID  = new SelectList(db.MinLoLUltimates, "UltimateID", "UltimateName", minLoLChampion.UltimateID);
            return(View(minLoLChampion));
        }
Esempio n. 3
0
        // GET: MinLoLChampions/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            MinLoLChampion minLoLChampion = db.MinLoLChampions.Find(id);

            if (minLoLChampion == null)
            {
                return(HttpNotFound());
            }
            return(View(minLoLChampion));
        }
Esempio n. 4
0
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            MinLoLChampion minLoLChampion = db.MinLoLChampions.Find(id);
            string         p1             = minLoLChampion.ChampIcon;
            string         p2             = minLoLChampion.ChampPic;

            TempData["Icon"] = p1;
            TempData["Pic"]  = p2;
            if (minLoLChampion == null)
            {
                return(HttpNotFound());
            }
            ViewBag.ChampRoleID = new SelectList(db.MinLoLRoles, "ChampRoleID", "RoleName", minLoLChampion.ChampRoleID);
            ViewBag.UltimateID  = new SelectList(db.MinLoLUltimates, "UltimateID", "UltimateName", minLoLChampion.UltimateID);
            return(View(minLoLChampion));
        }