public IHttpActionResult GetFriendFriendsPreview(string username) { var wantedUser = this.Data .Users .All() .FirstOrDefault(u => u.UserName == username); if (wantedUser == null) { return(this.NotFound()); } var currentUserId = this.UserIdProvider.GetUserId(); var currentUser = this.Data.Users.Find(currentUserId); var userFriends = wantedUser.Friends .AsQueryable() .Take(6) .Select(UserViewModelMinified.Create(currentUser)); return(this.Ok(new { TotalCount = wantedUser.Friends.Count, Friends = userFriends })); }
public IHttpActionResult GetFriendFriendsData(string username) { var wantedUser = this.Data .Users .All() .FirstOrDefault(u => u.UserName == username); if (wantedUser == null) { return(this.NotFound()); } var currentUserId = this.UserIdProvider.GetUserId(); if (currentUserId == null) { return(this.BadRequest()); } var currentUser = this.Data.Users.Find(currentUserId); var userFriends = wantedUser.Friends .AsQueryable() .Select(UserViewModelMinified.Create(currentUser)); return(this.Ok(userFriends)); }
public static PostLikeViewModel Create(PostLike postLike) { return(new PostLikeViewModel() { PostId = postLike.PostId, User = UserViewModelMinified.Create(postLike.User) }); }
public static CommentLikeViewModel Create(CommentLike commentLike) { return(new CommentLikeViewModel() { CommentId = commentLike.CommentId, User = UserViewModelMinified.Create(commentLike.User) }); }
public static FriendRequestViewModel Create(FriendRequest request) { return(new FriendRequestViewModel() { Id = request.Id, Status = request.Status, User = UserViewModelMinified.Create(request.From) }); }
public static CommentViewModel Create(Comment c, ApplicationUser currentUser) { return(new CommentViewModel() { Id = c.Id, Author = UserViewModelMinified.Create(c.Author), LikesCount = c.Likes.Count, CommentContent = c.Content, Date = c.Date, Liked = c.Likes .Any(l => l.UserId == currentUser.Id) }); }
public IHttpActionResult SearchUsers([FromUri] SearchBindingModel bindingModel) { var currentUserId = this.UserIdProvider.GetUserId(); var currentUser = this.Data.Users.Find(currentUserId); var users = this.Data .Users .All() .OrderBy(u => u.Name) .ThenBy(u => u.UserName) .Where(u => u.Name.Contains(bindingModel.SearchWord)) .Take(5) .Select(UserViewModelMinified.Create(currentUser)); return(this.Ok(users)); }
public IHttpActionResult GetFriendsPreviewData() { var currentUserId = this.UserIdProvider.GetUserId(); var currentUser = this.Data.Users.Find(currentUserId); var friends = currentUser.Friends .AsQueryable() .Take(6) .Select(UserViewModelMinified.Create(currentUser)); return(this.Ok(new { totalCount = currentUser.Friends.Count, friends })); }
public IHttpActionResult GetFriendsData() { var userId = this.UserIdProvider.GetUserId(); if (userId == null) { return(this.BadRequest()); } var user = this.Data.Users.Find(userId); var friends = user.Friends .AsQueryable() .Select(UserViewModelMinified.Create(user)); return(this.Ok(friends)); }
public static Expression <Func <Group, GroupViewModel> > Create(ApplicationUser currentUser) { return(group => new GroupViewModel { Id = group.Id, Name = group.Name, CoverImageData = group.CoverImageData, CreatedOn = group.CreatedOn, Description = group.Description, Admins = group.Admins .AsQueryable() .Select(UserViewModelMinified.Create(currentUser)), Members = group.Members .AsQueryable() .Select(UserViewModelMinified.Create(currentUser)), Posts = group.Posts .AsQueryable() .Select(GroupPostViewModel.Create(currentUser)) }); }
public static GroupViewModel ConvertTo(Group group, ApplicationUser currentUser) { GroupViewModel viewModel = new GroupViewModel { Id = group.Id, Name = group.Name, CoverImageData = group.CoverImageData, CreatedOn = group.CreatedOn, Description = group.Description, Admins = group.Admins .AsQueryable() .Select(UserViewModelMinified.Create(currentUser)), Members = group.Members .AsQueryable() .Select(UserViewModelMinified.Create(currentUser)), Posts = group.Posts .AsQueryable() .Select(GroupPostViewModel.Create(currentUser)) }; return(viewModel); }