예제 #1
0
        public ActionResult EditPicture(GalleryViewModel wvm)
        {
            if (ModelState.IsValid)
            {
                var picture = _uow.Gallery.Get(wvm.Id);
                var dept    = _uow.Gallery.Find(s => s.Name == wvm.Name).FirstOrDefault();
                if (picture != null)
                {
                    string fileName  = Path.GetFileNameWithoutExtension(wvm.PictureThumbnailUrl.FileName);
                    string extension = Path.GetExtension(wvm.PictureThumbnailUrl.FileName);
                    fileName       = fileName + DateTime.Now.ToString("yymmssffff") + extension;
                    wvm.PictureUrl = fileName;
                    fileName       = Path.Combine(Server.MapPath("~/Content/Images/"), fileName);

                    picture.Name                = wvm.Name;
                    picture.EventDate           = wvm.Date;
                    picture.PictureDescription  = wvm.Description;
                    picture.PictureUrl          = wvm.PictureUrl;
                    picture.PictureThumbnailUrl = wvm.PictureUrl;
                    if (wvm.PictureThumbnailUrl != null && wvm.PictureThumbnailUrl.ContentLength > 0)
                    {
                        wvm.PictureThumbnailUrl.SaveAs(fileName);
                    }

                    _uow.Commit();
                    TempData["message"] = $"{picture.Name} was successfully edited ";
                }
                return(RedirectToAction("Index"));
            }
            else
            {
                return(View(wvm));
            }
        }
예제 #2
0
        public ActionResult Gallery(GalleryViewModel gvm)
        {
            if (ModelState.IsValid)
            {
                var member = _uow.Gallery.Find(r => r.Name == gvm.Name).FirstOrDefault();

                string fileName  = Path.GetFileNameWithoutExtension(gvm.PictureThumbnailUrl.FileName);
                string extension = Path.GetExtension(gvm.PictureThumbnailUrl.FileName);
                fileName       = fileName + DateTime.Now.ToString("yymmssffff") + extension;
                gvm.PictureUrl = fileName;
                fileName       = Path.Combine(Server.MapPath("~/Content/Images/"), fileName);

                gvm.PictureThumbnailUrl.SaveAs(fileName);

                var _picture = new Gallery
                {
                    Name                = gvm.Name,
                    EventDate           = gvm.Date,
                    PictureUrl          = gvm.PictureUrl,
                    PictureThumbnailUrl = gvm.PictureUrl,
                    PictureDescription  = gvm.Description
                };

                _uow.Gallery.Add(_picture);
                _uow.Commit();
                TempData["message"] = string.Format("{0} has been saved.", gvm.Name);
                return(RedirectToAction("Index"));
            }
            else
            {
                var member = _uow.Members.GetAll().Select(r => r.MemberName);

                return(View(gvm));
            }
        }
예제 #3
0
        public ActionResult EditPicture(int id)
        {
            var picture = _uow.Gallery.Get(id);

            var wvm = new GalleryViewModel
            {
                Name        = picture.Name,
                Date        = picture.EventDate,
                Description = picture.PictureDescription,

                PictureUrl = picture.PictureUrl
            };

            return(View(wvm));
        }