Exemplo n.º 1
0
 public ShowPhotoDetailCommand(PhotoRepository photoRepository, PhotoDetailViewModel viewModel,
                               IMessenger messenger)
 {
     _messenger       = messenger;
     _photoRepository = photoRepository;
     _viewModel       = viewModel;
 }
Exemplo n.º 2
0
 public ActionResult Create(PhotoDetailViewModel photoDetailViewModel, HttpPostedFileBase file)
 {
     if (ModelState.IsValid)
     {
         PhotoDTO photoDto  = Mapper.Map <PhotoDTO>(photoDetailViewModel);
         byte[]   imageData = null;
         if (file != null)
         {
             if (file.ContentLength > (500 * 1024))
             {
                 ModelState.AddModelError("ImageUploadValidationError", "File size must be less than 500 Kb");
                 return(View(photoDetailViewModel));
             }
             if (!file.IsJpgImage())
             {
                 ModelState.AddModelError("ImageUploadValidationError", "File type allowed : jpeg");
                 return(View(photoDetailViewModel));
             }
             photoDto.ImageId       = _imageServices.SaveImageToDb(file.InputStream, Enums.ImageSize.Actual);
             photoDto.SmallImageId  = _imageServices.SaveImageToDb(file.InputStream, Enums.ImageSize.Small);
             photoDto.MiddleImageId = _imageServices.SaveImageToDb(file.InputStream, Enums.ImageSize.Middle);
             photoDto.Created       = DateTime.Now;
         }
         _photoServices.CreatePhoto(photoDto);
         return(RedirectToAction("Index"));
     }
     return(View(photoDetailViewModel));
 }
        public ActionResult GetPhotoDetail(int id)
        {
            var photos = DatabaseSession
                         .Query <Photo>()
                         .Select(x => new PhotoItemDto
            {
                PhotoId          = x.PhotoId,
                InsertedDateTime = x.InsertedDateTime,
            })
                         .ToList().OrderBy(x => x.PhotoId).ToList();


            var index      = photos.IndexOf(photos.Single(x => x.PhotoId == id));
            var previousId = index > 0 ? photos[index - 1].PhotoId : (int?)null;
            var nextId     = index < photos.Count - 1 ? photos[index + 1].PhotoId : (int?)null;

            var viewModel = new PhotoDetailViewModel();

            viewModel.PhotoUploadLinkURL   = "";
            viewModel.PreviousPhotoLinkURL = this.GetURL(c => c.GetPhotoDetail(id));
            viewModel.NextPhotoLinkURL     = this.GetURL(c => c.GetPhotoDetail(id));
            if (previousId.HasValue)
            {
                viewModel.HasPreviousPhotoLinkURL = true;
                viewModel.PreviousPhotoLinkURL    = this.GetURL(c => c.GetPhotoDetail(previousId.Value));
            }
            if (nextId.HasValue)
            {
                viewModel.HasNextPhotoLinkURL = true;
                viewModel.NextPhotoLinkURL    = this.GetURL(c => c.GetPhotoDetail(nextId.Value));
            }

            viewModel.PhotoViewModel = new PhotoViewModel(DatabaseSession.Get <Photo>(id), "", this);
            return(View(viewModel));
        }
Exemplo n.º 4
0
 public PhotoDetailPage(int pictureId)
 {
     InitializeComponent();
     _viewModel = new PhotoDetailViewModel {
         CurrentPictureId = pictureId
     };
     BindingContext             = _viewModel;
     ContentGrid.BindingContext = _viewModel;
 }
Exemplo n.º 5
0
 public ActionResult Edit(PhotoDetailViewModel photoDetailViewModel)
 {
     if (ModelState.IsValid)
     {
         PhotoDTO photoDto = Mapper.Map <PhotoDTO>(photoDetailViewModel);
         _photoServices.UpdatePhoto(photoDto);
         return(RedirectToAction("Details", new { id = photoDetailViewModel.Id }));
     }
     return(View(photoDetailViewModel));
 }
Exemplo n.º 6
0
        // GET: /Album/Edit/5
        public ActionResult Edit(Guid id)
        {
            PhotoDTO photoDto = _photoServices.GetPhoto(id);

            if (photoDto == null)
            {
                return(HttpNotFound());
            }
            PhotoDetailViewModel photoDetailViewModel = Mapper.Map <PhotoDetailViewModel>(photoDto);

            return(View(photoDetailViewModel));
        }
Exemplo n.º 7
0
        /// <summary>
        /// Invoked when this page is about to be displayed in a Frame.
        /// </summary>
        /// <param name="e">Event data that describes how this page was reached.
        /// This parameter is typically used to configure the page.</param>
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            ApplicationView appView = ApplicationView.GetForCurrentView();

            appView.SetDesiredBoundsMode(ApplicationViewBoundsMode.UseCoreWindow);
            if (e.Parameter != null)
            {
                string imagePath = (string)e.Parameter;
                Debug.WriteLine("inside photo detail page" + imagePath);
                viewModel        = new PhotoDetailViewModel(imagePath);
                this.DataContext = viewModel;
            }
        }
Exemplo n.º 8
0
        public PhotoDetailPage()
        {
            InitializeComponent();

            var item = new Photo
            {
                Id          = "Item 1",
                Description = "This is an item description."
            };

            viewModel      = new PhotoDetailViewModel(item);
            BindingContext = viewModel;
        }
Exemplo n.º 9
0
        public ActionResult Details(Guid id)
        {
            PhotoDTO photoDto = _photoServices.GetPhoto(id);

            if (photoDto == null)
            {
                return(HttpNotFound());
            }
            PhotoDetailViewModel   photoDetailViewModel = Mapper.Map <PhotoDetailViewModel>(photoDto);
            List <PhotoCommentDTO> photoCommentsDto     = _commentServices.GetCommentsByPhoto(id).OrderByDescending(x => x.Created).ToList();

            photoDetailViewModel.Comments = Mapper.Map <List <PhotoCommentDTO>, List <PhotoCommentViewModel> >(photoCommentsDto);
            return(View(photoDetailViewModel));
        }
Exemplo n.º 10
0
        public virtual ActionResult Detail(string categorySlug, string photoSlug)
        {
            var photo = _context.FindPhotoBySlug(photoSlug);

            if (photo == null || !string.Equals(photo.Category.Slug, categorySlug, StringComparison.CurrentCulture))
            {
                return(HttpNotFound());
            }

            if (!photo.IsApproved && (HttpContext.FindUser().UserId != photo.UserId || HttpContext.FindUser().IsAdmin))
            {
                return(HttpNotFound());
            }

            _context.CreateUserPhotoAction(HttpContext.FindUser(false)?.UserId, photo.PhotoId, UserPhotoActionType.View, false);

            var model = new PhotoDetailViewModel {
                Photo = photo, PhotosCount = _context.FindPhotoCountsByUserId(photo.User.UserId), ViewsCount = _context.FindUserPhotoActionsCountByType(photo.PhotoId, UserPhotoActionType.View), LikesCount = _context.FindUserPhotoActionsCountByType(photo.PhotoId, UserPhotoActionType.Like), CommentsCount = _context.FindCommentsCountByPhotoId(photo.PhotoId), DownloadsCount = _context.FindUserPhotoActionsCountByType(photo.PhotoId, UserPhotoActionType.Download), IsLiked = Request.IsAuthenticated && _context.HasUserPhotoAction(HttpContext.FindUser().UserId, photo.PhotoId, UserPhotoActionType.Like), LikedUsers = _context.FindUserPhotoActionsByType(photo.PhotoId, UserPhotoActionType.Like), Comments = _context.FindCommentsByPhotoId(photo.PhotoId, 1, int.MaxValue)
            };

            return(View(Views.Detail, model));
        }
Exemplo n.º 11
0
 public SavePhotoCommand(PhotoRepository photoRepository, PhotoDetailViewModel viewModel, IMessenger messenger)
 {
     this.photoRepository = photoRepository;
     this.viewModel       = viewModel;
     this.messenger       = messenger;
 }
Exemplo n.º 12
0
        public PhotoDetailPage(PhotoDetailViewModel viewModel)
        {
            InitializeComponent();

            BindingContext = this.viewModel = viewModel;
        }