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



            Nyhedstabel Nyheds = nf.Get(ID);

            if (Nyheds.Image != null)
            {
                string imagePath = Request.PhysicalApplicationPath + "/ArticleImages/" + Nyheds.Image;

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

            nf.Delete(ID);

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


            input.Image    = null;
            input.Dato     = null;
            input.BrugerID = null;

            if (Photo != null)
            {
                Nyhedstabel nyheds = nf.Get(input.ID);

                if (nyheds.Image != null)
                {
                    string imagePath = Request.PhysicalApplicationPath + "/Content/Images/Nyheder/" + nyheds.Image;

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

            nf.Update(input);


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

            input.Dato  = DateTime.Now;
            input.Image = null;

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


            nf.Insert(input);

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