Beispiel #1
0
        public ActionResult DelCategory(int Id)
        {
            CategoryGalleryDAO dao = new CategoryGalleryDAO();

            dao.DelCategory(Id);
            return(Redirect("/Home/Gallery/"));
        }
Beispiel #2
0
        public ActionResult AddGallery(string Category, string Name, string Folder, IEnumerable <HttpPostedFileBase> uploads)
        {
            CategoryGalleryDAO dao = new CategoryGalleryDAO();

            ViewBag.Categories = dao.GetListCategories();
            ViewBag.Count      = dao.GetCountCategories();
            var folder = Server.MapPath("~/Content/Gallery/" + Folder);

            if (!Directory.Exists(folder))
            {
                Directory.CreateDirectory(folder);
                foreach (var file in uploads)
                {
                    if (file != null)
                    {
                        string filename = Path.GetFileName(file.FileName);
                        file.SaveAs(Server.MapPath("~/Content/Gallery/" + Folder + "/" + filename));
                    }
                }

                GalleryDAO galleryDAO = new GalleryDAO();
                galleryDAO.AddGallery(Category, Name, Folder, uploads);
            }
            else
            {
                ViewBag.Warning = "Галерея с таким именем уже существует!";
            }
            return(View());
        }
Beispiel #3
0
        public ActionResult AddCategoryGallery(CategoryGallery category)
        {
            CategoryGalleryDAO dao = new CategoryGalleryDAO();

            dao.AddCategory(category);
            return(View());
        }
Beispiel #4
0
        public ActionResult AddGallery()
        {
            CategoryGalleryDAO dao = new CategoryGalleryDAO();

            ViewBag.Categories = dao.GetListCategories();
            ViewBag.Count      = dao.GetCountCategories();
            return(View());
        }
Beispiel #5
0
 public ActionResult GalleryName(string id)
 {
     if (string.IsNullOrEmpty(id))
     {
         return(Redirect("/Error/Http404"));
     }
     try
     {
         int cathId             = Convert.ToInt32(id);
         CategoryGalleryDAO dao = new CategoryGalleryDAO();
         var category           = dao.GetCategoryId(cathId);
         if (category == null)
         {
             return(Redirect("/Error/Http404"));
         }
         return(View(category));
     }
     catch (Exception)
     {
         return(Redirect("/Error/Http404"));
     }
 }
Beispiel #6
0
        public ActionResult Gallery()
        {
            CategoryGalleryDAO dao = new CategoryGalleryDAO();

            return(View(dao.GetListCategories()));
        }