// Returns a list of users who match the board game search parameter public List <AspNetUsers> SearchMatchBoardGames(string gameTitle) { GamerMatchContext db = new GamerMatchContext(); List <AspNetUsers> matchList = new List <AspNetUsers>(); ViewBag.Title = gameTitle; List <string> gameList = new List <string>(); string userGames = null; foreach (AspNetUsers user in db.AspNetUsers) { if (user.BoardGamePref != null) { userGames = user.BoardGamePref; gameList = GetBoardGames(userGames); foreach (string game in gameList) { if (game == gameTitle) { matchList.Add(user); } } } } return(matchList); }
// Calls the API controller to compare the search parameter to another user's Steam library public async Task <List <AspNetUsers> > SearchMatchSteam(string gameSearch) { GamerMatchContext db = new GamerMatchContext(); List <AspNetUsers> matchList = new List <AspNetUsers>(); ViewBag.Title = gameSearch; foreach (AspNetUsers user in db.AspNetUsers) { if (user.SteamInfo != null) { try { if (await apiController.SearchGames(user.SteamInfo, gameSearch) != null) { matchList.Add(user); } } catch (KeyNotFoundException) { continue; } } } return(matchList); }
public IActionResult RateUser(string username, int rating) { AspNetUsers activeUser = FindUser(); GamerMatchContext db = new GamerMatchContext(); foreach (MatchTable match in db.MatchTable) { if (username == match.UserGet && activeUser.Id == match.UserSend) { if (match.Rating == null) { match.Rating = rating; db.Update(match); continue; } else { return(Redirect("~/Home/HomePage")); } } } db.SaveChanges(); foreach (var person in db.AspNetUsers) { if (person.UserName == username) { if (person.PlayerRating == null) { person.PlayerRating = 0; person.RatingCount = 0; } person.PlayerRating += rating; person.RatingCount += 1; db.Update(person); } } db.SaveChanges(); return(Redirect("~/Home/HomePage")); }
public List <string> GetBans(AspNetUsers currentUser) { GamerMatchContext db = new GamerMatchContext(); List <string> userList = new List <string>(); List <MatchTable> matchList = db.MatchTable.ToList <MatchTable>(); foreach (MatchTable match in matchList) { if (match.UserSend == currentUser.Id) { if (match.Status == 2) { userList.Add(match.UserGet); } } } return(userList); }
public IActionResult Clear() { AspNetUsers activeUser = FindUser(); GamerMatchContext db = new GamerMatchContext(); foreach (MatchTable match in db.MatchTable) { if (match.UserSend == activeUser.Id) { if (match.Status == 2) { match.Status = 3; } } } db.SaveChanges(); return(Redirect("~/Home/HomePage")); }