Exemple #1
0
        public ActionResult DeleteConfirmed(int id)
        {
            MinLoLUltimate minLoLUltimate = db.MinLoLUltimates.Find(id);

            db.MinLoLUltimates.Remove(minLoLUltimate);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Exemple #2
0
        // GET: MinLoLUltimates/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            MinLoLUltimate minLoLUltimate = db.MinLoLUltimates.Find(id);

            if (minLoLUltimate == null)
            {
                return(HttpNotFound());
            }
            return(View(minLoLUltimate));
        }
Exemple #3
0
        public ActionResult Create([Bind(Include = "UltimateID,UltimateName,UltimateIcon,UltimatePic,UltimateDescription,UltimateCost")] MinLoLUltimate minLoLUltimate,
                                   IEnumerable <HttpPostedFileBase> files)
        {
            if (ModelState.IsValid)
            {
                //empty strings
                string icon    = "";
                string ultipic = "";
                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(minLoLUltimate));
                        }
                        if (ext == ".png")
                        {
                            icon = Guid.NewGuid() + ext;
                            file.SaveAs(Server.MapPath("~/Content/Ultimates/Icons/" + icon));
                        }
                        else if (ext == ".jpg")
                        {
                            ultipic = Guid.NewGuid() + ext;
                            file.SaveAs(Server.MapPath("~/Content/Ultimates/Pic/" + ultipic));
                        }
                    }
                }
                //add img values to object

                minLoLUltimate.UltimateIcon = icon;
                minLoLUltimate.UltimatePic  = ultipic;
                db.MinLoLUltimates.Add(minLoLUltimate);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(minLoLUltimate));
        }
Exemple #4
0
        // GET: MinLoLUltimates/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            MinLoLUltimate minLoLUltimate = db.MinLoLUltimates.Find(id);

            string p1 = minLoLUltimate.UltimateIcon;
            string p2 = minLoLUltimate.UltimatePic;

            TempData["Icon"] = p1;
            TempData["Pic"]  = p2;

            if (minLoLUltimate == null)
            {
                return(HttpNotFound());
            }
            return(View(minLoLUltimate));
        }