示例#1
0
        public async Task <ActionResult> Manage()
        {
            var user    = GetUser();
            var tagUses = await _tagHandler.GetAllTagUsesAsync(user.Id);

            var vm = new ManagePageViewModel()
            {
                User    = Mapper.Map <UserViewModel>(user),
                TagUses = Mapper.Map <ICollection <TagUseViewModel> >(tagUses),
            };

            return(View(vm));
        }
示例#2
0
        public async Task <ActionResult> Manage(string titleSearch = "", string tag = null)
        {
            var user = GetUser();
            var vm   = await PrepareManagePageViewModel(
                user.Id, null, titleSearch, tag, PublishingStatusConditionKind.All, 0, WebConsts.RefListsPageSize,
                RefListSortKind.UpdatedDateDescending
                );

            vm.Author = Mapper.Map <UserViewModel>(user);

            var tagUses = await _tagHandler.GetAllTagUsesAsync(user.Id);

            vm.OwnedTagUses = tagUses.Select(u => u.Name);

            return(View(vm));
        }
示例#3
0
        public async Task <ActionResult> Detail(string userName, string titleSearch = "", string tag = null)
        {
            if (string.IsNullOrWhiteSpace(userName))
            {
                return(RedirectToAction("Index", "User"));
            }

            var author = await _UserHandler.GetUserByUserNameAsync(userName);

            BusinessContract.Require(author != null, Errors.UserNotFound, userName);

            /// 非公開設定の確認のため本人でもPublishしか見れないようにする。
            var req = new GetRefListsRequest(
                author.Id, null, null, tag, titleSearch, null, PublishingStatusConditionKind.PublishOnly, 0, WebConsts.RefListsPageSize,
                RefListSortKind.PublishedDateDescending
                );
            var result = await _refListHandler.GetRefListsAsync(req);

            var tagUses = await _tagHandler.GetAllTagUsesAsync(author.Id);

            var vm = new DetailPageViewModel()
            {
                Author       = Mapper.Map <UserViewModel>(author),
                OwnedTagUses = Mapper.Map <ICollection <TagUseViewModel> >(tagUses),
                TitleSearch  = titleSearch,
                TagUse       = tag,
                PageIndex    = result.PageIndex + 1,
                PageCount    = result.PageCount,
                RefLists     = Mapper.Map <ICollection <RefListViewModel> >(result.RefLists),
            };

            var isFavored = false;

            if (IsAuthenticated())
            {
                var user = GetUser();
                isFavored = await _favoriteHandler.ExistsFavoriteUserAsync(user.Id, author.Id);
            }
            vm.IsFavored = isFavored;

            return(View(vm));
        }