Ejemplo n.º 1
0
        public virtual ActionResult GetEventImagesbyEvent(long id)
        {
            _objuser = new UserPresenter();
            var model = _objuser.GetAllGalleryEvnetImagesById(id).ToList();

            SessionManager.NewsEventsList = _objuser.GetnewseventsList();
            return(View(model));
        }
Ejemplo n.º 2
0
        public virtual ActionResult AddEventGallery(EventGalleryModel model, HttpPostedFileBase[] file1)
        {
            if (model.Id == 0)
            {
                if (model.ThumbnailImage == null)
                {
                    ModelState.AddModelError("ImageUpload", "Please upload Thumbnail Image");
                    ViewBag.error = "ImageUpload: Please upload Thumbnail Image";
                }

                if (file1 != null)
                {
                    if (file1[0] == null && model.Id == 0)
                    {
                        ModelState.AddModelError("ImageUpload", "Please upload Event Image");
                        ViewBag.error = "ImageUpload: Please upload Event Image";
                    }
                }
            }

            #region Check File Upload Thumbnail
            string filename = string.Empty;

            var httpPostedFileBase = Request.Files[0];
            if (httpPostedFileBase != null && (Request.Files.Count > 0 && httpPostedFileBase.FileName != string.Empty))
            {
                if (Request.Files[0].FileName != string.Empty)
                {
                    filename = UploadDocument();
                }

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

            #endregion

            if (ModelState.IsValid && model != null)
            {
                _objuser = new UserPresenter();
                if (model.ThumbnailImage == null)
                {
                    var get = _objuser.GetGalleryEventById(model.Id);
                    if (get != null)
                    {
                        if (get.ThumbnailImage != null)
                        {
                            model.ThumbnailImage = get.ThumbnailImage;
                        }
                    }
                }
                else
                {
                    model.ThumbnailImage = filename == string.Empty ? string.Empty : "UploadedImages/" + filename;
                }
                if (filename != string.Empty)
                {
                    SaveDocument(filename);
                }
                if (file1 != null)
                {
                    model.ImagesBases = file1;
                }
                _objuser.AddneventGallery(model);
                return(RedirectToAction(MVC.Admin.EventGalleryList()));
            }

            if (model.Id != 0)
            {
                var getimages = _objuser.GetAllGalleryEvnetImagesById(model.Id);
                if (getimages != null)
                {
                    model.Images         = getimages.ToList();
                    model.ThumbnailImage = _objuser.GetGalleryEventById(model.Id).ThumbnailImage;
                }
            }
            ModelState.AddModelError("", "Please upload all the required fields marked with *");
            ViewBag.error = "Please upload all the required fields";
            return(View(model));
        }