Example #1
0
 public static FriendsAndPendingsModel ConvertToFriendsAndPendingsModel(List <User> pendings, List <User> friends)
 {
     return(new FriendsAndPendingsModel
     {
         Pendings = pendings.Select(x => SimpleUserModel.ConvertToSimpleUserModel(x)).ToList(),
         Friends = friends.Select(x => SimpleUserModel.ConvertToSimpleUserModel(x)).ToList()
     });
 }
Example #2
0
 public static SimpleGroupModel ConvertToSimpleGroupModel(Group group)
 {
     return(new SimpleGroupModel
     {
         Id = group.Id,
         Name = group.Name,
         Image = group.Image,
         Description = group.Description,
         Adminstrator = SimpleUserModel.ConvertToSimpleUserModel(group.Administrator)
     });
 }
Example #3
0
 public static UsersModel ConvertToUsersModel(User user, User loggedUser)
 {
     return(new UsersModel
     {
         User = SimpleUserModel.ConvertToSimpleUserModel(user),
         IsUser = user.Id == loggedUser.Id,
         IsPending = loggedUser.Pendings.Any(x => x.Pending.Id == user.Id),
         IsFriend = user.Friends.Any(x => x.Friend.Id == loggedUser.Id),
         IsInvite = user.Pendings.Any(x => x.Pending.Id == loggedUser.Id)
     });
 }
Example #4
0
 public static SimplePostModel ConvertToSimplePostModel(Post post)
 {
     return(new SimplePostModel
     {
         Id = post.Id,
         Title = post.Title,
         Message = post.Message,
         Image = post.Image,
         Date = post.Date,
         User = SimpleUserModel.ConvertToSimpleUserModel(post.User),
         Likes = post.Likes.Select(x => SimpleUserModel.ConvertToSimpleUserModel(x.User)).ToList()
     });
 }
Example #5
0
 public static GroupProfileModel ConvertToSimpleUserModel(Group group, List <Tournament> tournaments)
 {
     return(new GroupProfileModel
     {
         Id = group.Id,
         Name = group.Name,
         Image = group.Image,
         Description = group.Description,
         Administrator = SimpleUserModel.ConvertToSimpleUserModel(group.Administrator),
         Users = group.Users.Select(x => SimpleUserModel.ConvertToSimpleUserModel(x.User)).ToList(),
         TournamentsNotFinished = tournaments.Where(x => !x.Finished).Select(x => SimpleTournamentModel.ConvertToSimpleTournamentModel(x)).ToList(),
         TournamentsFinished = tournaments.Where(x => x.Finished).Select(x => SimpleTournamentModel.ConvertToSimpleTournamentModel(x)).ToList()
     });
 }
Example #6
0
        public static SimpleTournamentModel ConvertToSimpleTournamentModel(Tournament tournament)
        {
            var winner = tournament.Winner != null?SimpleUserModel.ConvertToSimpleUserModel(tournament.Winner) : null;

            return(new SimpleTournamentModel
            {
                Id = tournament.Id,
                Name = tournament.Name,
                Image = tournament.Image,
                Finished = tournament.Finished,
                Winner = winner,
                StartDate = tournament.StartDate,
                Feedback = tournament.Feedback
            });
        }
Example #7
0
 public static ProfileModel ConvertToProfileModel(User user, User loggedUser, List<Group> groups)
 {
     return new ProfileModel
     {
         Id = user.Id,
         Name = user.Name,
         LastName = user.LastName,
         Nickname = user.Nickname,
         Avatar = user.Avatar,
         Pendings = user.Pendings.Select(x => SimpleUserModel.ConvertToSimpleUserModel(x.Pending)).ToList(),
         Friends = user.Friends.Select(x => SimpleUserModel.ConvertToSimpleUserModel(x.Friend)).ToList(),
         Groups = groups.Select(x => SimpleGroupModel.ConvertToSimpleGroupModel(x)).ToList(),
         IsUser = user.Id == loggedUser.Id,
         IsPending = loggedUser.Pendings.Any(x => x.Pending.Id == user.Id),
         IsFriend = user.Friends.Any(x => x.Friend.Id == loggedUser.Id),
         IsInvite = user.Pendings.Any(x => x.Pending.Id == loggedUser.Id)
     };
 }