Ejemplo n.º 1
0
        public virtual ActionResult AddGallery(GalleryModel gallery)
        {
            string filename = string.Empty;

            #region Check File Upload
            var httpPostedFileBase = Request.Files[0];
            if (httpPostedFileBase != null && (Request.Files.Count > 0 && httpPostedFileBase.FileName != string.Empty))
            {
                if (Request.Files[0].FileName != string.Empty)
                {
                    gallery.ImagePath = null;
                    filename          = UploadDocument();
                    if (filename == string.Empty)
                    {
                        return(View());
                    }
                }

                else
                {
                    ViewBag.message = "Please upload the Image";
                    return(View());
                }
            }

            #endregion

            if (ModelState.IsValid)
            {
                _objuser            = new UserPresenter();
                gallery.CreateDate  = DateTime.Now;
                gallery.IsActivated = true;
                if (gallery.ImagePath != null)
                {
                    filename = gallery.ImagePath;
                }
                else
                {
                    gallery.ImagePath = filename == string.Empty ? string.Empty : "UploadedImages/" + filename;
                }
                if (filename != string.Empty)
                {
                    SaveDocument(filename);
                }
                var ioutput = _objuser.AddImages(gallery);
                return(RedirectToAction(MVC.Admin.GalleryView()));
            }
            else
            {
                string message = "Inavlid data";
                ModelState.AddModelError("", message);
            }
            return(View());
        }
Ejemplo n.º 2
0
 public virtual ActionResult AddVideo(VideoGalleryModel gallery)
 {
     if (ModelState.IsValid)
     {
         _objuser = new UserPresenter();
         var ioutput = _objuser.AddImages(gallery);
         return(RedirectToAction(MVC.Admin.VideoGalleryListView()));
     }
     else
     {
         const string message = "Inavlid data";
         ModelState.AddModelError("", message);
     }
     return(View());
 }