public IActionResult Search() { ViewBag.Tags = TagsMapper.MapRange(_photosService.Tags); return(View()); }
/// <summary> /// Loads all tags and returns collection of tag DTOs. /// </summary> public IEnumerable <TagDTO> GetAll() { return(TagsMapper.MapRange(_unitOfWork.Tags.GetAll())); }
public IEnumerable <TagViewModel> GetAll() { return(TagsMapper.MapRange(_tagsService.GetAll())); }
/// <summary> /// Helps map photo data transfer object. /// </summary> protected PhotoDTO MapPhoto(Photo photo) { User currentUser = _currentUserService.Get; if (currentUser == null) { var likes = new List <LikeDTO>(photo.Likes.Count); foreach (var like in photo.Likes) { likes.Add(LikesMapper.Map(like, UsersMapper.Map( like.Owner, _unitOfWork.Confirmations.Find(c => c.UserId == like.OwnerId).FirstOrDefault() != null, false, false, false ))); } var comments = new List <CommentDTO>(photo.Comments.Count); foreach (var comment in photo.Comments) { comments.Add(CommentsMapper.Map( comment, UsersMapper.Map( comment.Owner, _unitOfWork.Confirmations.Find(c => c.UserId == comment.OwnerId).FirstOrDefault() != null, false, false, false ))); } return(PhotosMapper.Map( photo, false, false, UsersMapper.Map( photo.Owner, _unitOfWork.Confirmations.Find(c => c.UserId == photo.OwnerId).FirstOrDefault() != null, false, false, false ), likes, comments, TagsMapper.MapRange(_unitOfWork.Tagings.Find(t => t.PhotoId == photo.Id).Select(t => t.Tag)))); } if (_unitOfWork.Blockings.Find(b => b.BlockedUserId == currentUser.Id && b.UserId == photo.OwnerId).FirstOrDefault() == null) { var likes = new List <LikeDTO>(photo.Likes.Count); foreach (var like in photo.Likes) { likes.Add(LikesMapper.Map(like, UsersMapper.Map( like.Owner, _unitOfWork.Confirmations.Find(c => c.UserId == like.OwnerId).FirstOrDefault() != null, _unitOfWork.Followings.Find(f => f.FollowedUserId == like.OwnerId && f.UserId == currentUser.Id).FirstOrDefault() != null, _unitOfWork.Blockings.Find(b => b.BlockedUserId == like.OwnerId && b.UserId == currentUser.Id).FirstOrDefault() != null, _unitOfWork.Blockings.Find(b => b.BlockedUserId == currentUser.Id && b.UserId == currentUser.Id).FirstOrDefault() != null ))); } var comments = new List <CommentDTO>(photo.Comments.Count); foreach (var comment in photo.Comments) { comments.Add(CommentsMapper.Map( comment, UsersMapper.Map( comment.Owner, _unitOfWork.Confirmations.Find(c => c.UserId == comment.OwnerId).FirstOrDefault() != null, _unitOfWork.Followings.Find(f => f.FollowedUserId == comment.OwnerId && f.UserId == currentUser.Id).FirstOrDefault() != null, _unitOfWork.Blockings.Find(b => b.BlockedUserId == comment.OwnerId && b.UserId == currentUser.Id).FirstOrDefault() != null, _unitOfWork.Blockings.Find(b => b.BlockedUserId == currentUser.Id && b.UserId == currentUser.Id).FirstOrDefault() != null ))); } return(PhotosMapper.Map( photo, _unitOfWork.Likes.Find(l => l.OwnerId == currentUser.Id && l.PhotoId == photo.Id).FirstOrDefault() != null, _unitOfWork.Bookmarks.Find(b => b.UserId == currentUser.Id && b.PhotoId == photo.Id).FirstOrDefault() != null, UsersMapper.Map( photo.Owner, _unitOfWork.Confirmations.Find(c => c.UserId == photo.OwnerId).FirstOrDefault() != null, _unitOfWork.Followings.Find(f => f.FollowedUserId == photo.OwnerId && f.UserId == currentUser.Id).FirstOrDefault() != null, _unitOfWork.Blockings.Find(b => b.BlockedUserId == photo.OwnerId && b.UserId == currentUser.Id).FirstOrDefault() != null, _unitOfWork.Blockings.Find(b => b.BlockedUserId == currentUser.Id && b.UserId == photo.OwnerId).FirstOrDefault() != null ), likes, comments, TagsMapper.MapRange(_unitOfWork.Tagings.Find(t => t.PhotoId == photo.Id).Select(t => t.Tag)))); } return(null); }