public ActionResult Index() { var model = new ProfileViewModel() { Player = GetUser().Player, Yours = true }; model.SingleMatches = DataAccess.SingleMatches .Where(m => m.Tournament.Published) .Where(m => m.Player1.Id == model.Player.Id || m.Player2.Id == model.Player.Id) .Where(m => m.Player1 != null && m.Player2 != null && m.Winner != null) .ToList(); model.PairMatches = DataAccess.PairMatches .Where(m => m.Tournament.Published) .Where(m => m.Pair1 != null && m.Pair2 != null && m.Winner != null) .Where(m => m.Pair1.Player1.Id == model.Player.Id || m.Pair1.Player2.Id == model.Player.Id || m.Pair2.Player1.Id == model.Player.Id || m.Pair2.Player2.Id == model.Player.Id) .ToList(); return View(model); }
public ActionResult Profile(int id) { var model = new ProfileViewModel() { Player = DataAccess.Players.FirstOrDefault(p => p.Id == id) }; model.SingleMatches = DataAccess.SingleMatches .Where(m => m.Tournament.Published) .Where(m => m.Player1.Id == model.Player.Id || m.Player2.Id == model.Player.Id) .Where(m => m.Player1 != null && m.Player2 != null && m.Winner != null) .ToList(); model.PairMatches = DataAccess.PairMatches .Where(m => m.Tournament.Published) .Where(m => m.Pair1 != null && m.Pair2 != null && m.Winner != null) .Where(m => m.Pair1.Player1.Id == id || m.Pair1.Player2.Id == id || m.Pair2.Player1.Id == id || m.Pair2.Player2.Id == id) .ToList(); return View(model); }