Ejemplo n.º 1
0
        public OperationResultVo <GameViewModel> GetById(Guid currentUserId, Guid id, bool forEdit)
        {
            try
            {
                Game model = gameDomainService.GetById(id);

                GameViewModel vm = mapper.Map <GameViewModel>(model);

                vm.LikeCount     = model.Likes.SafeCount(x => x.GameId == vm.Id);
                vm.FollowerCount = model.Followers.SafeCount(x => x.GameId == vm.Id);

                vm.CurrentUserLiked     = model.Likes.SafeAny(x => x.GameId == vm.Id && x.UserId == currentUserId);
                vm.CurrentUserFollowing = model.Followers.SafeAny(x => x.GameId == vm.Id && x.UserId == currentUserId);

                UserProfile authorProfile = GetCachedProfileByUserId(vm.UserId);
                vm.AuthorName = authorProfile.Name;

                if (forEdit)
                {
                    FormatExternalLinksForEdit(ref vm);
                }

                FormatExternalLinks(vm);

                FilCharacteristics(vm);

                return(new OperationResultVo <GameViewModel>(vm));
            }
            catch (Exception ex)
            {
                return(new OperationResultVo <GameViewModel>(ex.Message));
            }
        }