Example #1
0
 public ActionResult SubImageUpdate(int id)
 {
     if (User.Identity.IsAuthenticated)
     {
         if (id != 0)
         {
             SlideMod slideUpdate = db.getSlide(id) as SlideMod;
             if (slideUpdate != null)
             {
                 stockView.AdminPanel         = db.getAdminPanel();
                 stockView.SlideList          = db.getSlideList(slideUpdate.StockId);
                 stockView.PrdCategory        = db.getProductsCategory();
                 stockView.prdSubCategorylist = db.getSubProducts();
                 stockView.Slide         = slideUpdate;
                 stockView.SubImageCount = stockView.SlideList.Count;
                 ViewBag.SubImgForDelete = slideUpdate.PhotoPath;
                 return(View("GetSubImage", stockView));
             }
             else
             {
                 return(HttpNotFound());
             }
         }
         else
         {
             return(HttpNotFound());
         }
     }
     else
     {
         return(RedirectToAction("Login", "Logon"));
     }
 }
Example #2
0
 public ActionResult DeleteSubImage(int Id, int StockId)
 {
     if (User.Identity.IsAuthenticated)
     {
         if (Id != 0)
         {
             SlideMod slShow = db.getSlide(Id) as SlideMod;
             bool     result = db.deleteSubImage(Id);
             if (result && slShow != null)
             {
                 string imgPath = Server.MapPath("~/Content/SlideImage/" + slShow.PhotoPath);
                 if (System.IO.File.Exists(imgPath))
                 {
                     System.IO.File.Delete(imgPath);
                 }
                 else
                 {
                     return(RedirectToAction("GetSubImage", new { Id = StockId }));
                 }
             }
             else
             {
                 HttpNotFound();
             }
         }
         return(HttpNotFound());
     }
     else
     {
         return(RedirectToAction("Login", "Logon"));
     }
 }
Example #3
0
 public ActionResult SubImageAdd(SlideMod slide, HttpPostedFileBase PhotoPath)
 {
     if (User.Identity.IsAuthenticated)
     {
         if (slide != null && PhotoPath != null)
         {
             string imagePath = (DateTime.Now.Hour + "" + DateTime.Now.Minute + "" + DateTime.Now.Second + "" + PhotoPath.FileName).ToString();
             bool   result;
             if (slide.Id == 0)
             {
                 slide.PhotoPath = imagePath;
                 result          = db.insertSlide(slide);
                 if (result)
                 {
                     PhotoPath.SaveAs(Server.MapPath("/Content/SlideImage/" + imagePath));
                     return(RedirectToAction("GetSubImage", new { stockId = slide.StockId }));
                 }
                 else
                 {
                     return(HttpNotFound());
                 }
             }
             else
             {
                 slide.PhotoPath = imagePath;
                 result          = db.updateSlide(slide);
                 if (result)
                 {
                     if (System.IO.File.Exists(Server.MapPath("/Content/SlideIamge/" + ViewBag.SubImgForDelete)))
                     {
                         System.IO.File.Delete(Server.MapPath("/Content/SlideIamge/" + ViewBag.SubImgForDelete));
                     }
                     else
                     {
                         return(HttpNotFound());
                     }
                     return(HttpNotFound());
                 }
                 else
                 {
                     return(HttpNotFound());
                 }
             }
         }
         else
         {
             return(HttpNotFound());
         }
     }
     else
     {
         return(RedirectToAction("Login", "Logon"));
     }
 }