Exemplo n.º 1
0
        public FollowingDto GetFollowing(string authorName)
        {
            var userId    = ClaimsPrincipal.Current.Claims.FirstOrDefault(x => x.Type == ClaimTypes.NameIdentifier)?.Value ?? "0";
            var following = _followingRepository.GetFollowing(authorName, int.Parse(userId));

            return(_followingMapper.Map(following));
        }
Exemplo n.º 2
0
            public Model Handle(Query message)
            {
                var attendances  = _attendanceRepository.GetAllAttendances();
                var photographer = _applicationUserRepository.GetPhotographer(message.PhotographerId);

                var following = _applicationUserRepository.GetPhotographerFollowers(message.PhotographerId);
                var followers = _applicationUserRepository.GetPhotographerFollowing(message.PhotographerId);

                var upcomingExhibits  = _exhibitRepository.GetUpcomingExhibitsByPhotographer(message.PhotographerId);
                var attendingExhibits = _exhibitRepository.GetExhibitsUserAttending(message.PhotographerId);

                var isFollowing = _followingRepository.GetFollowing(message.UserId, message.PhotographerId) != null;

                var model = new Model
                {
                    PhotographerId    = message.PhotographerId,
                    PhotographerName  = photographer.Name,
                    PhotographerEmail = photographer.Email,
                    UserId            = message.UserId,
                    ShowActions       = message.ShowActions,
                    Attendances       = attendances.Select(a => new Model.Attendance
                    {
                        ExhibitId  = a.ExhibitId,
                        AttendeeId = a.AttendeeId
                    }).ToList(),
                    IsFollowing = isFollowing,
                    Heading     = "[Users] Exhibits"
                };

                if (photographer.ImageUrl != null)
                {
                    model.ImageUrl = _urlComposer.ComposeImgUrl(photographer.ImageUrl);
                }

                model.UpcomingExhibits = upcomingExhibits.Select(ue => new Model.Exhibit
                {
                    Id             = ue.Id,
                    PhotographerId = ue.PhotographerId,
                    Location       = ue.Location,
                    ImageUrl       = _urlComposer.ComposeImgUrl(ue.ImageUrl),
                    DateTime       = ue.DateTime,
                    IsCanceled     = ue.IsCanceled,
                    Genre          = new Model.Exhibit.GenreT {
                        Name = ue.Genre.Name
                    },
                    Photographer = new Model.PhotographerT {
                        Name = ue.Photographer.Name
                    }
                }).ToList();

                model.AttendingExhibits = attendingExhibits.Select(ae => new Model.Exhibit
                {
                    Id             = ae.Id,
                    PhotographerId = ae.PhotographerId,
                    Location       = ae.Location,
                    ImageUrl       = _urlComposer.ComposeImgUrl(ae.ImageUrl),
                    DateTime       = ae.DateTime,
                    IsCanceled     = ae.IsCanceled,
                    Genre          = new Model.Exhibit.GenreT {
                        Name = ae.Genre.Name
                    },
                    Photographer = new Model.PhotographerT {
                        Name = ae.Photographer.Name
                    }
                }).ToList();

                model.Followers = followers.Select(f => new Model.PhotographerT
                {
                    Id       = f.Id,
                    Name     = f.Name,
                    ImageUrl = _urlComposer.ComposeImgUrl(f.ImageUrl),
                    Email    = f.Email,
                }).ToList();

                model.Following = following.Select(f => new Model.PhotographerT
                {
                    Id       = f.Id,
                    Name     = f.Name,
                    ImageUrl = _urlComposer.ComposeImgUrl(f.ImageUrl),
                    Email    = f.Email,
                }).ToList();

                return(model);
            }