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() }); }
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) }); }
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) }); }
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() }); }
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() }); }
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 }); }
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) }; }