예제 #1
0
        public async Task <ActionResult> PostInGroup(GroupProfileModel model)
        {
            try
            {
                var authUser = await BasicUserFacade.GetUserByNickNameAsync(User.Identity.Name);

                var post = new GroupProfilePostDto()
                {
                    PostedAt      = DateTime.Now.ToUniversalTime(),
                    StayAnonymous = model.PostStayAnonymous,
                    GroupId       = model.GroupProfile.Id,
                    Text          = model.NewPostText
                };
                if (!post.StayAnonymous)
                {
                    post.UserId = authUser.Id;
                }
                await GroupProfileFacade.PostInGroup(post);

                return(RedirectToAction("Index", new { groupId = model.GroupProfile.Id }));
            }
            catch
            {
                return(RedirectToAction("Index", new { groupId = model.GroupProfile.Id }));
            }
        }
        // GET: InviteUsersToGroup
        public async Task <ActionResult> Index([FromUri] string subname = "", int?groupId = null)
        {
            var filter = new UserFilterDto {
                SubName = subname
            };

            var user = await BasicUserFacade.GetUserByNickNameAsync(User.Identity.Name);

            var users = await BasicUserFacade.GetUsersBySubnameAsync(subname);

            var basicUserDtos = users as IList <BasicUserDto> ?? users.ToList();

            foreach (var u in basicUserDtos)
            {
                await BasicUserFacade.AssignGroupsToUserAsync(u);
            }

            var basicUserWithFriends = await BasicUserFacade.GetBasicUserWithGroups(user.Id);

            return(View("InviteUsersToGroupView", new InviteUsersToGroupModel
            {
                Filter = filter,
                Users = basicUserDtos,
                User = basicUserWithFriends,
                GroupId = groupId
            }));
        }
예제 #3
0
        // GET: GroupProfile
        public async Task <ActionResult> Index(int groupId)
        {
            var groupProfile = await GroupProfileFacade.GetGroupProfileAsync(groupId);

            var authUser = await BasicUserFacade.GetUserByNickNameAsync(User.Identity.Name);

            var userGroups = await BasicUserFacade.GetBasicUserWithGroups(authUser.Id);

            var group = await GroupGenericFacade.GetAsync(groupId);

            if (userGroups.Groups.Where(groupUser => groupUser.Group.Id == groupId || !group.IsPrivate).IsNullOrEmpty())
            {
                throw new HttpException(404, "Some description");
            }
            else
            {
                return(View("GroupProfile", new GroupProfileModel
                {
                    GroupProfile = groupProfile,
                    AuthenticatedUser = authUser
                }));
            }
        }
예제 #4
0
        // GET: Posts
        public async Task <ActionResult> Index(PostFilterDto postFilter)
        {
            //defaultni hodnota pagesize je 50 - zvysuje se po lichych cislech, takze je to v poho (y)
            if (postFilter.PageSize == 50)
            {
                postFilter = new PostFilterDto()
                {
                    SortCriteria = nameof(Post.PostedAt),
                    PageSize     = Posts
                };
            }

            //priprava na pagination
            Session[PostFilterSessionKey] = postFilter;
            var commentFilter = Session[CommentFilterSessionKey] as CommentFilterDto ?? new CommentFilterDto()
            {
                PageSize = Comments
            };

            var posts = await UserProfileFacade.GetPostsWithUsersNicknamesAndCommentsByFilters(postFilter, commentFilter);

            BasicUserDto userWithFriends = null;

            if (Request.IsAuthenticated)
            {
                var user = await BasicUserFacade.GetUserByNickNameAsync(User.Identity.Name);

                userWithFriends = await BasicUserFacade.GetBasicUserWithFriends(user.Id);
            }

            return(View("Index", new PostListModel()
            {
                PostFilter = postFilter,
                AuthenticatedUser = userWithFriends,
                Posts = posts
            }));
        }