public ActionResult Details(DetailsPhotoViewModel photo)
        {
            var picture = _photoRepository.FindById(photo.Id);

            photo.MapPhoto(picture);

            return(View(photo));
        }
Beispiel #2
0
        public ActionResult Details(DetailsPhotoViewModel photo)
        {
            Photo photoFromDB = photoRepository.GetPhotoFromDbById(photo.Id);

            photo = PhotoMapper.MapDetailsPhotoViewModel(photoFromDB);

            return(PartialView("_PhotoDetail", photo));
        }
        public ActionResult AddComment(CommentViewModel model)
        {
            model.Commenter = User.Identity.Name;
            _commentRepository.Add(model.MapComment());

            var photo   = new DetailsPhotoViewModel();
            var picture = _photoRepository.FindById(model.PhotoId);

            photo.MapPhoto(picture);

            return(PartialView("Comments", photo.Comments));
        }
Beispiel #4
0
        internal static Photo MapDetailsPhotoViewModel(DetailsPhotoViewModel photoView, IPhotoRepository PhotoBI)
        {
            var photo = PhotoBI.GetPhotoFromDbById(photoView.Id);

            photo.Description = photoView.Description;
            photo.Name        = photoView.Name;
            photo.Path        = photoView.Path;

            photoView.Comments.ToList().ForEach(x =>
                                                photo.Comments.Add(new Comment {
                Content = x.comment,
                Date    = DateTime.Parse(x.date),
                UserID  = x.userID
            }));

            return(photo);
        }
Beispiel #5
0
        public static void MapPhoto(this DetailsPhotoViewModel detailsPhoto, Photo photo)
        {
            detailsPhoto.Id = photo.Id;
            detailsPhoto.Name = photo.Name;
            detailsPhoto.Description = photo.Description;
            detailsPhoto.FileName = photo.FileName;
            detailsPhoto.UploadedBy = photo.User.Name;

            photo.Comments.ToList().ForEach(x => detailsPhoto.Comments.Add(
                new CommentViewModel
                {
                    Commenter = x.User.Name,
                    Comment = x.Text,
                    Date = x.Date
                }
                ));
        }
Beispiel #6
0
        public ActionResult Details(DetailsPhotoViewModel photo, FormCollection collection)
        {
            var comment = new Comment
            {
                Date    = DateTime.Now,
                Content = collection["comment"],
                UserID  = UserHelper.GetLogedInUser(userRepository).Id,
                PhotoID = photo.Id
            };

            commentRepository.AddComment(comment);

            Photo photoFromDB = photoRepository.GetPhotoFromDbById(photo.Id);

            photo = PhotoMapper.MapDetailsPhotoViewModel(photoFromDB);

            return(View(photo));
        }
Beispiel #7
0
        internal static DetailsPhotoViewModel MapDetailsPhotoViewModel(Photo photoFromDB)
        {
            var photo = new DetailsPhotoViewModel();

            photo.Name         = photoFromDB.Name;
            photo.Description  = photoFromDB.Description;
            photo.Path         = photoFromDB.Path;
            photo.Date         = photoFromDB.Date;
            photo.UploaderName = photoFromDB.User.Name;
            photo.Album        = photoFromDB.AlbumID != null ? photoFromDB.Album.Name : "Uncategorized";

            photoFromDB.Comments.ToList().ForEach(x =>
                                                  photo.Comments.Add(new CommentViewModel
            {
                id      = x.Id,
                email   = x.User.Email,
                name    = x.User.Name,
                date    = x.Date.ToString(),
                comment = x.Content
            }));

            return(photo);
        }