예제 #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 }));
            }
        }
예제 #2
0
        public async Task <ActionResult> KickUser(int groupid, int userid)
        {
            await GroupProfileFacade.RemoveUserFromGroup(groupid, userid);

            return(RedirectToAction("ShowGroupUsers", new
            {
                groupId = groupid
            }));
        }
예제 #3
0
        public async Task <ActionResult> MakeAdmin(int groupid, int userid)
        {
            await GroupProfileFacade.MakeUserAdminAsync(groupid, userid);

            return(RedirectToAction("ShowGroupUsers", new
            {
                groupId = groupid
            }));
        }
예제 #4
0
        public async Task <ActionResult> ShowGroupUsers(int groupId)
        {
            var groupUsers = await GroupProfileFacade.GetGroupUsers(groupId);

            var group = await GroupGenericFacade.GetAsync(groupId);

            return(View("GroupUsers", new ShowGroupUsersModel
            {
                Group = group,
                GroupUsers = groupUsers
            }));
        }
예제 #5
0
        public async Task <ActionResult> AddComment(GroupProfileModel model)
        {
            try
            {
                var comment = new CommentDto
                {
                    Text     = model.NewCommentText,
                    PostedAt = DateTime.Now.ToUniversalTime(),
                    UserId   = model.AuthenticatedUser.Id,
                    PostId   = model.PostId
                };

                await GroupProfileFacade.AddComment(comment);

                return(RedirectToAction("Index", new { groupId = model.GroupProfile.Id }));
            }
            catch
            {
                return(RedirectToAction("Index", new { groupId = model.GroupProfile.Id }));
            }
        }
예제 #6
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
                }));
            }
        }
예제 #7
0
        public async Task <ActionResult> DeletePost(GroupProfileModel model)
        {
            await GroupProfileFacade.DeletePost(model.PostId);

            return(RedirectToAction("Index", new { groupId = model.GroupProfile.Id }));
        }