public ActionResult GetPortfolio(int?portId)
        {
            PortfolioSection selectedPort = db.PortfolioSections.Find(portId);

            ViewBag.portfolio = selectedPort;
            return(PartialView("_PortfolioInfo"));
        }
Пример #2
0
        public ActionResult Edit(int?id, PortfolioSection portfolioSection, HttpPostedFileBase Photo)
        {
            if (id == null)
            {
                return(HttpNotFound());
            }
            PortfolioSection selectedPort = db.PortfolioSections.First(x => x.id == id);

            if (Photo != null)
            {
                if (System.IO.File.Exists(Server.MapPath(selectedPort.imageUrl)))
                {
                    System.IO.File.Delete(Server.MapPath(selectedPort.imageUrl));
                }
                WebImage img    = new WebImage(Photo.InputStream);
                FileInfo file   = new FileInfo(Photo.FileName);
                string   imgUrl = Guid.NewGuid().ToString() + file.Extension;
                img.Save("~/Images/" + imgUrl);
                selectedPort.imageUrl = "/Images/" + imgUrl;
            }
            selectedPort.header      = portfolioSection.header;
            selectedPort.deccription = portfolioSection.deccription;
            selectedPort.publishDate = portfolioSection.publishDate;
            selectedPort.categoryId  = portfolioSection.categoryId;
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Пример #3
0
        public ActionResult Delete(int?portId)
        {
            PortfolioSection port = db.PortfolioSections.Find(portId);

            db.PortfolioSections.Remove(port);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Пример #4
0
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(HttpNotFound());
            }
            PortfolioSection selectedPort = db.PortfolioSections.FirstOrDefault(p => p.id == id);

            if (selectedPort == null)
            {
                return(HttpNotFound());
            }
            return(View(selectedPort));
        }
Пример #5
0
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(HttpNotFound());
            }
            PortfolioSection selectedPort = db.PortfolioSections.FirstOrDefault(p => p.id == id);

            ViewBag.categories = db.Categories.ToList();
            if (selectedPort == null)
            {
                return(HttpNotFound());
            }
            return(View(selectedPort));
        }
Пример #6
0
 public ActionResult Create(PortfolioSection portfolioSection, HttpPostedFileBase Photo)
 {
     if (Photo != null)
     {
         WebImage img    = new WebImage(Photo.InputStream);
         FileInfo file   = new FileInfo(Photo.FileName);
         string   imgUrl = Guid.NewGuid().ToString() + file.Extension;
         img.Save("~/Images/" + imgUrl);
         portfolioSection.imageUrl = "/Images/" + imgUrl;
     }
     ViewBag.categories = db.Categories.ToList();
     db.PortfolioSections.Add(portfolioSection);
     db.SaveChanges();
     return(RedirectToAction("Index"));
 }