public UserSearchGameView GetUserSearch(int userSearchId) { var userSearch = userSearches.GetUserSearch(userSearchId); var game = games.GetGame(userSearch.GameId); return(mappingService.GetUserSearchGameView(game, userSearch)); }
public UserGameView GetUserGame(int gameId, int userId) { var usergame = userGames.GetUserGame(gameId, userId); var game = games.GetGame(usergame.GameId); var genre = games.GetGenre(game.GenreId).Name; return(mappingService.GetUserGameView(game, genre, usergame)); }
public GameDto GetGameDetails(int id) { var game = games.GetGame(id); if (game is null) { return(null); } return(mappingService.GetGameDtoFromGame(game)); }
/// <summary> /// Gets a specific guild from the Guilds database table /// </summary> /// <param name="id">Unique ID of the targeted guild</param> /// <returns>Targeted guild object</returns> public async Task <GuildsDTO> GetGuild(int id) { Guilds guild = await _context.Guilds.FindAsync(id); List <GameGuilds> gameGuilds = await _context.GameGuilds.Where(x => x.GuildId == id).ToListAsync(); List <GamesDTO> games = new List <GamesDTO>(); foreach (var item in gameGuilds) { games.Add(await _games.GetGame(item.GameId)); } GuildsDTO dto = new GuildsDTO() { Name = guild.Name, Games = games, Id = guild.Id }; foreach (var item in games) { item.Guilds = null; } return(dto); }
public async Task <ActionResult <GamesDTO> > GetGame(int id) { var games = await _games.GetGame(id); if (games == null) { return(NotFound()); } return(games); }
public IEnumerable <ExchangeView> GetMyExchanges(int userId) { var myExchanges = exchanges.GetUserExchanges(userId); List <ExchangeView> exchangeViews = new List <ExchangeView>(); foreach (var exchange in myExchanges) { var newExchangeView = new ExchangeView() { ExchangeId = exchange.ExchangeId, Shipment = exchange.Shipment, State = exchange.State }; if (exchange.OfferingUserId == userId) { newExchangeView.AmIOffering = true; var user = userProfiles.GetUserProfile(exchange.OtherUserId); newExchangeView.OtherUserName = user.Name + " " + user.Surname; newExchangeView.UserImage = user.ImageUrl; newExchangeView.OtherUserId = exchange.OtherUserId; var myGames = exchange.OfferingUsersGames.Split(',').ToArray(); var otherUserGames = exchange.OtherUsersGames.Split(',').ToArray(); for (int i = 0; i < myGames.Count(); i++) { var g = games.GetGame(Int32.Parse(myGames[i])); myGames[i] = g.Title; } for (int i = 0; i < otherUserGames.Count(); i++) { otherUserGames[i] = games.GetGame(Int32.Parse(otherUserGames[i])).Title; } newExchangeView.MyGames = myGames; newExchangeView.OtherUserGames = otherUserGames; newExchangeView.MyFinalizeTime = exchange.OfferingUserFinalizeTime; newExchangeView.OtherUserFinalizeTime = exchange.OtherUserFinalizeTime; } else { newExchangeView.AmIOffering = false; var user = userProfiles.GetUserProfile(exchange.OfferingUserId); newExchangeView.OtherUserName = user.Name + " " + user.Surname; newExchangeView.UserImage = user.ImageUrl; newExchangeView.OtherUserId = exchange.OfferingUserId; var myGames = exchange.OtherUsersGames.Split(',').ToArray(); var otherUserGames = exchange.OfferingUsersGames.Split(',').ToArray(); for (int i = 0; i < myGames.Count(); i++) { myGames[i] = games.GetGame(Int32.Parse(myGames[i])).Title; } for (int i = 0; i < otherUserGames.Count(); i++) { otherUserGames[i] = games.GetGame(Int32.Parse(otherUserGames[i])).Title; } newExchangeView.MyGames = myGames; newExchangeView.OtherUserGames = otherUserGames; newExchangeView.MyFinalizeTime = exchange.OtherUserFinalizeTime; newExchangeView.OtherUserFinalizeTime = exchange.OfferingUserFinalizeTime; } if (newExchangeView.MyFinalizeTime.Year >= 2018) { newExchangeView.HaveIFinalized = true; } exchangeViews.Add(newExchangeView); } return(exchangeViews); }