public ActionResult PhotoDetails(int id)
        {
            PhotoDetailsViewModel photo = photoService.GetById(id).ToPhotoDetailsViewModel();

            photo.Owner = accountService.GetUserById(photo.UserId).ToPhotoOwnerViewModel();
            if (Request.IsAuthenticated)
            {
                photo.CurrentUserId = accountService.GetUserByLogin(User.Identity.Name).Id;
            }

            PageInfo pageInfo = new PageInfo
            {
                PageNumber = 1,
                PageSize   = CommentOnPage,
                TotalItems = photoService.CountCommentByPhotoId(id)
            };
            IEnumerable <CommentViewModel> comments = photoService.GetCommentsByPhotoId(id, 0, CommentOnPage)
                                                      .Select(p => p.ToCommentViewModel());

            ViewBag.Comments = new PaginationViewModel <CommentViewModel> {
                PageInfo = pageInfo, Items = comments
            };

            return(PartialView("_PhotoDetails", photo));
        }
示例#2
0
        protected override async void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);

            var navigationArgs = e.Parameter.ToString();

            var loadData = e.NavigationMode != NavigationMode.Back;

            _viewModel  = ServiceLocator.Current.GetInstance <PhotoDetailsViewModel>(loadData);
            DataContext = _viewModel;

            if (loadData)
            {
                if (navigationArgs.Contains(typeof(PhotoDetailsViewModelArgs).Name))
                {
                    var photoDetailsViewModelArgs =
                        SerializationHelper.Deserialize <PhotoDetailsViewModelArgs>(navigationArgs);
                    await _viewModel.LoadState(photoDetailsViewModelArgs);
                }
                else if (navigationArgs.Contains(typeof(PhotoDetailsViewModelPhotoIdArgs).Name))
                {
                    var photoDetailsViewModelIdArgs =
                        SerializationHelper.Deserialize <PhotoDetailsViewModelPhotoIdArgs>(navigationArgs);
                    await _viewModel.LoadState(photoDetailsViewModelIdArgs);
                }
            }
        }
        public PhotoDetailsPage(Photo photo)
        {
            InitializeComponent();
            NavigationPage.SetBackButtonTitle(this, "Back");

            viewModel       = SimpleIoc.Default.GetInstance <PhotoDetailsViewModel>();
            viewModel.Photo = photo;
            BindingContext  = viewModel;
        }
        public PhotoDetailsPage(PhotoDetailsViewModel viewModel)
        {
            InitializeComponent();
            this.viewModel    = viewModel;
            image.Source      = this.viewModel.Photo.ThumbnailUrl;
            title.Text        = this.viewModel.Photo.Title;
            thumbnailUrl.Text = this.viewModel.Photo.ThumbnailUrl;

            BindingContext = this.viewModel;
        }
        private PhotoDetailsViewModel prepareViewModel(FlickrUserResponse userResponse, FlickrPhotoDetailsResponse photoResponse)
        {
            var model = new PhotoDetailsViewModel();

            model.Description = photoResponse.photo.description._content;
            model.Title       = photoResponse.photo.title._content;
            model.PublishedOn = DateTime.Parse(photoResponse.photo.dates.taken).ToString("MMMM dd, yyyy 'at' hh:mm tt");
            model.Author      = userResponse.person.username._content;

            return(model);
        }
示例#6
0
        public ActionResult PhotoDetails(int Id)
        {
            //todo: retrieve this photos uploader
            #region retrieve photo to show
            PhotoDetailsViewModel model = null;

            using (PhotoExplorerEntities cx = new PhotoExplorerEntities())
            {
                PhotoEntityModel entity = cx.Photos
                                          .Where(p => p.Id == Id)
                                          .FirstOrDefault();

                ///todo: make this more effective..
                #region retrieve uploader of photoentity
                UserEntityModel photoOwnerEntity = null;
                foreach (var user in cx.Users)
                {
                    foreach (var album in user.Albums)
                    {
                        foreach (var photo in album.Photos)
                        {
                            if (photo.Id == Id)
                            {
                                photoOwnerEntity = user;
                                break;
                            }
                        }
                    }
                }
                #endregion


                model = new PhotoDetailsViewModel()
                {
                    Id          = entity.Id,
                    Name        = entity.Name,
                    FileName    = entity.FileName,
                    DateCreated = entity.DateCreated,
                    DateChanged = entity.DateChanged,
                    Album       = entity.Album,
                    Comments    = entity.Comments, //due to us already having the model collection initialized in the photodetailsviewmodel class, we only have to transfer the collection VALUES from the entity collection to the model collection.
                    Description = entity.Description,
                    User        = photoOwnerEntity,
                };
            }
            #endregion

            return(View(model));
        }
示例#7
0
        public ActionResult Comment(int id, string txt_comment)
        {
            PhotoDetailsViewModel model = null;

            using (PhotoExplorerEntities cx = new PhotoExplorerEntities())
            {
                // retrieve currently logged in user
                ClaimsIdentity  currentIdentity = User.Identity as ClaimsIdentity;
                int             userid          = int.Parse(currentIdentity.Claims.FirstOrDefault(u => u.Type == ClaimTypes.NameIdentifier).Value);
                UserEntityModel loggedInEntity  = cx.Users.FirstOrDefault(u => u.Id == userid);

                // initialize new comment entity
                CommentEntityModel commentModel = new CommentEntityModel()
                {
                    DateCreated = DateTime.Now,
                    Comment     = txt_comment,
                    Commenter   = loggedInEntity.Username,
                };

                // retrieve the photo entity commented on
                PhotoEntityModel entity = cx.Photos
                                          .Where(p => p.Id == id)
                                          .FirstOrDefault();

                entity.Comments.Add(commentModel);

                cx.SaveChanges();

                //mapping
                model = new PhotoDetailsViewModel()
                {
                    Name        = entity.Name,
                    Album       = entity.Album,
                    DateCreated = entity.DateCreated,
                    FileName    = entity.FileName,
                    Description = entity.Description,
                    Id          = entity.Id,
                    User        = loggedInEntity,
                    Comments    = entity.Comments,
                };
            }

            /*
             *  note: only updating portion of the page by using partial view (with the NEW model)
             */
            return(PartialView("_PhotoComments", model));
        }
示例#8
0
        public static PhotoDetailsViewModel EntityToModel(PhotoEntityModel entity)
        {
            PhotoDetailsViewModel model = new PhotoDetailsViewModel()
            {
                Id          = entity.Id,
                Name        = entity.Name,
                FileName    = entity.FileName,
                DateCreated = entity.DateCreated,
                DateChanged = entity.DateChanged,
                Album       = entity.Album,
                Comments    = entity.Comments,
                Description = entity.Description,
                User        = entity.User,
            };

            return(model);
        }
示例#9
0
        public ActionResult Details(int id)
        {
            var photo = photoAPI.FindPhotoById(id);

            if (photo == null)
            {
                return(HttpNotFound());
            }
            else
            {
                var model = new PhotoDetailsViewModel
                {
                    Photo    = photo.ToDetailsViewModel(),
                    Comments = photo.Comments.Select(x => x.toViewModel()).ToList()
                };

                return(View(model));
            }
        }
        public ActionResult PhotoDetails(string postId)
        {
            var userId             = User.Identity.GetUserId();
            var currentUserProfile = _userProfileService.GetUserProfileByUserId(new Guid(userId));
            var post      = _postService.GetPost(new Guid(postId));
            var viewModel = new PhotoDetailsViewModel
            {
                Post            = post,
                Votes           = post.Likes.Sum(x => x.Value),
                CurrentUserVote =
                    currentUserProfile != null
                        ? post.Likes.Where(l => l.UserProfile.Id == currentUserProfile.Id)
                    .Select(l => l.Value)
                    .FirstOrDefault()
                        : 0,
                Comments = _postService.GetComments(new Guid(postId))
            };

            return(View(viewModel));
        }
示例#11
0
        // GET: Gallery/Details/5
        public ViewResult Details(int?id)
        {
            if (id == null)
            {
                Response.StatusCode = 404;
                return(View("NotFound", null));
            }

            var photo = photoService.GetById(id.GetValueOrDefault());

            if (photo == null)
            {
                Response.StatusCode = 404;
                return(View("NotFound", id));
            }
            var photoDetailsViewModel = new PhotoDetailsViewModel
            {
                Photo     = photo,
                TagStr    = GetTags(photo),
                PageTitle = "Photo Details"
            };

            return(View(photoDetailsViewModel));
        }
示例#12
0
        public virtual ActionResult SocialBar(int eventid, int photoid)
        {
            var es = new EventService();
            var imgs = new ImageService();
            var ts = new TweetService();

            var model = new PhotoDetailsViewModel();
            var theEvent = es.FindByID(eventid);
            if (theEvent != null)
            {
                model.EventId = eventid;
                model.EventSlug = theEvent.EventSlug;
                model.Image = imgs.FindByID(photoid);
                model.Tweets = ts.FindByImageID(photoid, eventid);
                model.Event = theEvent;
                model.HashTag =
                    theEvent.SearchTerms.Split(new string[] { " OR " }, StringSplitOptions.None)[0].Contains("#")
                        ? theEvent.SearchTerms.Split(new string[] { " OR " }, StringSplitOptions.None)[0]
                        : "#" + theEvent.SearchTerms.Split(new string[] { " OR " }, StringSplitOptions.None)[0];
            }

            var apiClient = new Epilogr.APISoapClient();
            model.ShortURL = apiClient.CreateUrl("http://epilogger.com/events/PhotoDetails/" + eventid + "/" + photoid).ShortenedUrl;


            return PartialView(model);
        }
示例#13
0
        public ActionResult Details(int Id)
        {
            PhotoDetailsViewModel model = EFMapper.EntityToModel(photoRepo.GetPhoto(Id));

            using (PhotoExplorerEntities cx = new PhotoExplorerEntities())
            {
                foreach (var user in cx.Users)
                {
                    foreach (var album in user.Albums)
                    {
                        foreach (var photo in album.Photos)
                        {
                            if (photo.Id == Id)
                            {
                                model.User = user;
                                break;
                            }
                        }
                    }
                }
            }

            #region notused
            ////todo: retrieve this photos uploader
            //#region retrieve photo to show
            //PhotoDetailsViewModel model = null;

            //using (PhotoExplorerEntities cx = new PhotoExplorerEntities())
            //{
            //    PhotoEntityModel entity = cx.Photos
            //        .Where(p => p.Id == Id)
            //        .FirstOrDefault();

            //    ///todo: make this more effective..
            //    #region retrieve uploader of photoentity
            //    UserEntityModel photoOwnerEntity = null;
            //    foreach (var user in cx.Users)
            //    {
            //        foreach (var album in user.Albums)
            //        {
            //            foreach (var photo in album.Photos)
            //            {
            //                if (photo.Id == Id)
            //                {
            //                    photoOwnerEntity = user;
            //                    break;
            //                }
            //            }
            //        }
            //    }
            //    #endregion


            //    model = new PhotoDetailsViewModel()
            //    {
            //        Id = entity.Id,
            //        Name = entity.Name,
            //        FileName = entity.FileName,
            //        DateCreated = entity.DateCreated,
            //        DateChanged = entity.DateChanged,
            //        Album = entity.Album,
            //        Comments = entity.Comments, //due to us already having the model collection initialized in the photodetailsviewmodel class, we only have to transfer the collection VALUES from the entity collection to the model collection.
            //        Description = entity.Description,
            //        User = photoOwnerEntity,
            //    };
            //}
            //#endregion
            #endregion

            return(View("Details", model));
        }