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 })); } }
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 })); } }
public async Task <GroupProfileModel> GetProfileById(int id, User user) { var group = await GetOneById(id, user); if (group == null) { throw new NotFoundException("Grupo não existe."); } if (!group.Users.Any(x => x.UserId == user.Id)) { throw new BadRequestException("Você não está nesse grupo."); } var tournaments = await _context.Tournaments .Include(x => x.Group) .Include(x => x.Winner) .Where(x => group.Id == x.Group.Id) .ToListAsync(); return(GroupProfileModel.ConvertToSimpleUserModel(group, tournaments)); }
public async Task <ActionResult> DeletePost(GroupProfileModel model) { await GroupProfileFacade.DeletePost(model.PostId); return(RedirectToAction("Index", new { groupId = model.GroupProfile.Id })); }