Exemplo n.º 1
0
        public ActionResult Delete(int ID)
        {
            if (Session["rolle"] == null || (int)Session["rolle"] < Editor)
            {
                return(Redirect("/CMS/Produkt"));
            }



            ProduktTabellen produkt = pf.Get(ID);

            if (produkt.Billede != null)
            {
                string imagePath = Request.PhysicalApplicationPath + "/Content/Images/Produkter/" + produkt.Billede;

                if (System.IO.File.Exists(imagePath))
                {
                    System.IO.File.Delete(imagePath);
                }
            }

            pf.Delete(ID);

            return(Redirect("/CMS/Produkt"));
        }
Exemplo n.º 2
0
        public ActionResult Edit(ProduktTabellen input, HttpPostedFileBase Photo)
        {
            if (Session["rolle"] == null || (int)Session["rolle"] < Editor)
            {
                return(Redirect("/CMS/Produkt"));
            }


            input.Billede = null;

            if (Photo != null)
            {
                ProduktTabellen produkt = pf.Get(input.ID);

                if (produkt.Billede != null)
                {
                    string imagePath = Request.PhysicalApplicationPath + "/Content/Images/Produkter/" + produkt.Billede;

                    if (System.IO.File.Exists(imagePath))
                    {
                        System.IO.File.Delete(imagePath);
                    }
                }
                string newImagePath = Request.PhysicalApplicationPath + "/Content/Images/Produkter/";
                input.Billede = ft.ImageUpload(Photo, newImagePath);
            }

            pf.Update(input);


            return(Redirect("/CMS/Produkt"));
        }
Exemplo n.º 3
0
        public ActionResult AddNew(ProduktTabellen input, HttpPostedFileBase Photo)
        {
            if (Session["rolle"] == null || (int)Session["rolle"] < Editor)
            {
                return(Redirect("/CMS"));
            }


            input.Billede = null;

            if (Photo != null)
            {
                string imagePath = Request.PhysicalApplicationPath + "/Content/Images/Produkter/";
                input.Billede = ft.ImageUpload(Photo, imagePath);
            }


            pf.Insert(input);

            return(Redirect("/CMS/Produkt"));
        }