public async Task GetDetailsAsync_WithId_ShouldReturnTeamDetailsViewModel() { this.dbContext.Products.Add(new Product() { Title = string.Format(TestsConstants.Product, 1), TeamId = 1 }); this.dbContext.Products.Add(new Product() { Title = string.Format(TestsConstants.Product, 2), TeamId = 1 }); this.dbContext.SaveChanges(); var teamFromService = await this.service.GetDetails(1); var teamDetailsViewModel = new TeamDetailsViewModel() { Name = string.Format(TestsConstants.Team, 1), LogoUrl = string.Format(TestsConstants.Logo, 1) }; Assert.AreEqual(teamDetailsViewModel.LogoUrl, teamFromService.LogoUrl); Assert.AreEqual(teamDetailsViewModel.Name, teamFromService.Name); }
// GET: Teams/Details/5 public ActionResult Details(int?id) { if (id == null) { return(HttpNotFound()); } Team team = db.Teams.Find(id); var matches = db.Matches .Include(m => m.HomeTeam) .Include(m => m.AwayTeam) .Where(m => m.HomeTeamId == id || m.AwayTeamId == id) .OrderByDescending(m => m.DateTime) .ToList(); var teams = db.Teams .Where(t => t.LeagueId == team.LeagueId) .OrderByDescending(t => t.Points) .ThenByDescending(t => t.GoalsFor - t.GoalsAgainst) .ThenByDescending(t => t.GoalsFor) .ToList(); TeamDetailsViewModel viewModel = new TeamDetailsViewModel { Team = team, Matches = matches, League = db.Leagues.First(l => l.Id == team.LeagueId), Standings = teams }; return(View("Details", viewModel)); }
public async Task <ActionResult> Edit(TeamDetailsViewModel teamViewModel, IFormFile logoPath) { try { if (ModelState.IsValid) { if (logoPath != null) { string oldFilePath = ImgPath + teamViewModel.LogoPath; if (System.IO.File.Exists(_hostEnvironment.WebRootPath + oldFilePath)) { System.IO.File.Delete(_hostEnvironment.WebRootPath + oldFilePath); } teamViewModel.LogoPath = await logoPath.SaveImage(_hostEnvironment.WebRootPath, ImgPath); } await _teamService.UpdateAsync(_mapper.Map <Team>(teamViewModel)); return(RedirectToAction(nameof(Index))); } return(View(teamViewModel)); } catch { return(View(teamViewModel)); } }
public async Task <IActionResult> Details(int id) { TeamDetailsServiceModel team = null; try { team = await this._teamService.GetTeamDetailsAsync(id); } catch (System.Exception) { return(RedirectToAction("Error")); } TeamDetailsViewModel teamViewModel = new TeamDetailsViewModel() { Id = team.Id, Name = team.Name, Matches = team.Matches .Select(m => new MatchViewModel { Id = m.Id, HomeTeam = m.HomeTeam, AwayTeam = m.AwayTeam, MatchDay = m.MatchDay, HomeGoals = m.HomeGoals, AwayGoals = m.AwayGoals }) .ToList(), }; return(this.View(teamViewModel)); }
public async Task <TeamDetailsViewModel> TeamDetailsAsync(string name) { var teamName = name.Replace('-', ' '); var team = await this.database.Teams.Where(x => x.Name.ToLower() == teamName).FirstOrDefaultAsync(); var teamPhotoAlbums = await this.database.PhotoAlbums.Where(pa => pa.HomeTeamId == team.Id || pa.AwayTeamId == team.Id).ToListAsync(); var gamesPlayed = await this.database.Games.Where(g => (g.HomeTeamId == team.Id || g.AwayTeamId == team.Id) && g.DateAndStartTime.Contains("КРАЙ")).ToListAsync(); var teamDetails = new TeamDetailsViewModel { Id = team.Id, LogoUrl = team.LogoUrl, Name = team.Name, CoverPhotoUrl = team.CoverPhotoUrl, CoachName = team.CoachName, TrainingsDescription = team.TrainingsDescription, ContactUrl = team.ContactUrl, GamesPlayedCounter = gamesPlayed.Count, TeamPhotoAlbums = teamPhotoAlbums, }; return(teamDetails); }
// GET: Teams/Details/5 public async Task <IActionResult> Details(int?id, string sortOrder) { if (id == null) { return(NotFound()); } var viewModel = new TeamDetailsViewModel { Team = await _teamsService.GetTeamAsync(id.Value), }; if (viewModel.Team == null) { return(NotFound()); } Task <IEnumerable <Game> > last5Task = _gamesService.GetLastAsync(id.Value, 5); Task <IEnumerable <Game> > next3Task = _gamesService.GetNextAsync(id.Value, 3); Task <List <Standings> > confStandingTask = _standingsService.GetStandingsAsync(viewModel.Team.Conference); var allTasks = new List <Task> { last5Task, next3Task, confStandingTask }; while (allTasks.Any()) { Task finished = await Task.WhenAny(allTasks); if (finished == last5Task) { allTasks.Remove(last5Task); viewModel.Last5 = await last5Task; } else if (finished == next3Task) { allTasks.Remove(next3Task); viewModel.Next3 = await next3Task; } else if (finished == confStandingTask) { allTasks.Remove(confStandingTask); var standings = await confStandingTask; viewModel.ConferenceRank = standings.IndexOf(viewModel.Team.RecordNav) + 1; } } viewModel.PPGLeader = _teamsService.GetPPGLeader(viewModel.Team.PlayersNav.ToList()); viewModel.RPGLeader = _teamsService.GetRPGLeader(viewModel.Team.PlayersNav.ToList()); viewModel.APGLeader = _teamsService.GetAPGLeader(viewModel.Team.PlayersNav.ToList()); viewModel.Players = _teamsService.SortRoster(viewModel.Team.PlayersNav.ToList(), sortOrder); //for sorting ViewData["PosSortParam"] = String.IsNullOrEmpty(sortOrder) ? "pos_desc" : " "; ViewData["PlayerSortParam"] = sortOrder == "Player" ? "player_desc" : "Player"; ViewData["PPGSortParam"] = sortOrder == "PPG" ? "ppg_desc" : "PPG"; ViewData["RPGSortParam"] = sortOrder == "RPG" ? "rpg_desc" : "RPG"; ViewData["APGSortParam"] = sortOrder == "APG" ? "apg_desc" : "APG"; return(View(viewModel)); }
// GET: Teams/Details/5 public async Task <IActionResult> Details(int id) { Team team = _teamsService.GetTeamWithPlayers(id); if (team == null) { return(NotFound()); } var model = new TeamDetailsViewModel() { TeamName = team.Name, TeamId = team.Id, Players = team.Players.Select(x => new PlayerDetailsViewModel() { Id = x.Id, DateOfBirth = x.DateOfBirth, Email = x.Email, Name = x.Name, Nickname = x.Nickname, }).ToList(), LogoPath = String.Format("{0}{1}", team.Id, ".png"), IsAdmin = User.Identity.Name != null && team.TeamAdminEmails.Contains(User.Identity.Name) }; return(View(model)); }
public TeamDetailsViewPage(Team CurrentItem) { InitializeComponent(); var viewModel = new TeamDetailsViewModel(CurrentItem); viewModel.Navigation = this.Navigation; viewModel.Message = this; BindingContext = viewModel; }
public async Task <IActionResult> Details(int?id) { if (id == null) { return(NotFound()); } var team = await _context.Team .FirstOrDefaultAsync(t => t.Id == id); if (team == null) { return(NotFound()); } var captain = await _userManager.FindByIdAsync(team.CaptainId); int gameWins = _context.Game.Where(g => (g.TeamAId == team.Id && g.TeamAScore > g.TeamBScore) || (g.TeamBId == team.Id && g.TeamBScore > g.TeamAScore)).Count(); int gameLosses = _context.Game.Where(g => (g.TeamAId == team.Id && g.TeamAScore < g.TeamBScore) || (g.TeamBId == team.Id && g.TeamBScore < g.TeamAScore)).Count(); int gameTies = _context.Game.Where(g => (g.TeamAId == team.Id || g.TeamBId == team.Id) && (g.TeamAScore == g.TeamBScore && g.TeamAScore != null && g.TeamBScore != null)).Count(); var players = await( from au in _context.ApplicationUsers where au.TeamId == team.Id join p in _context.Position on au.PositionId equals p.Id into sub from subq in sub.DefaultIfEmpty() select new PlayerDetailsViewModel { Player = new ApplicationUser { Id = au.Id, FirstName = au.FirstName, LastName = au.LastName, PositionId = au.PositionId, RoleId = au.RoleId, TeamId = au.TeamId }, Position = subq.Name }).ToListAsync(); var currentUser = await GetCurrentUserAsync(); TeamDetailsViewModel viewModel = new TeamDetailsViewModel { Team = team, TeamCaptainFirstName = captain.FirstName, TeamCaptainLastName = captain.LastName, CurrentUser = currentUser, PlayerList = players, Wins = gameWins, Losses = gameLosses, Ties = gameTies }; return(View(viewModel)); }
public TeamDetails() { InitializeComponent(); _vm = new TeamDetailsViewModel(); this.DataContext = _vm; LoadingPopup ovr = new LoadingPopup(); loadingGrid.Visibility = System.Windows.Visibility.Collapsed; loadingGrid.Children.Add(ovr); }
public async Task GetDetailsAsync_WithId_ShouldReturnTypeofTeamDetailsViewModel() { var teamFromService = await this.service.GetDetails(1); var teamDetailsViewModel = new TeamDetailsViewModel() { Name = string.Format(TestsConstants.Test, 1), LogoUrl = string.Format(TestsConstants.Logo, 1) }; Assert.IsInstanceOfType(teamFromService, typeof(TeamDetailsViewModel)); }
public async Task <ActionResult> EditTeam(TeamDetailsViewModel model) { try { await TeamServiceClient.EditTeam(model.Id, model.TeamName); return(RedirectToAction("TeamList", "Team")); } catch (Exception e) { ViewBag.Message = e.Message; } return(View()); }
public async Task <ActionResult> AddNewTeam() { var model = new TeamDetailsViewModel(); try { model.CurrencyList = await AdminServiceClient.GetAllCurrency(); } catch (Exception e) { ViewBag.Message = e.Message; } return(View(model)); }
// GET: Teams/Details/5 public ActionResult Details(int id) { var team = Teams_db.GetList(x => x.Sport).SingleOrDefault(x => x.Id == id); var athletes = Athletes_db.GetList(x => x.TeamRole) .Where(x => x.TeamId == id); var viewModel = new TeamDetailsViewModel() { Team = team, Athletes = athletes }; return(View(viewModel)); }
public ActionResult Details(string teamName, string section = "") { if (string.IsNullOrEmpty(teamName)) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } TeamDetailsViewModel model = this.teamService.GetTeamDetails(teamName, section, this.User.Identity.GetUserId()); if (model == null) { return(new HttpStatusCodeResult(404)); } return(this.View(model)); }
// // GET: /Team/Details/5 public ActionResult Details(int id) { var query = new GetUserConfirmedTeamsQuery(HttpContext.User.Identity.GetUserId()); Team team = dispatcher.ExecuteQuery(query).FirstOrDefault(t => t.Id == id); if (team != null) { TeamDetailsViewModel teamViewModel = Mapper.Map <Team, TeamDetailsViewModel>(team); ApplicationUser currentUser = dispatcher.ExecuteQuery(new GetUserByIdQuery(HttpContext.User.Identity.GetUserId())); teamViewModel.IsEditable = CurrentUserIsOwnerOrTeamManager(currentUser, teamViewModel); return(View(teamViewModel)); } ViewBag.ErrorMessage = "You are not authorized to view this teams details"; return(View("NotAMemberOfATeam")); }
public async Task <ActionResult> EditTeamDetails(long id) { var model = new TeamDetailsViewModel(); try { model.CurrencyList = await AdminServiceClient.GetAllCurrency(); model.TeamDetails = await TeamServiceClient.GetTeamDetailsForEdit(id); } catch (Exception e) { ViewBag.Message = e.Message; } return(View(model)); }
/// <summary> /// Just for viewing superficial information about a team (no admin) /// </summary> public ActionResult TeamDetails(string team) { var teamMatch = _teamsRepository.GetMatchingTeamWithSlug(team); if (teamMatch != null) { var viewModel = new TeamDetailsViewModel() { Team = teamMatch, TeamMembers = new List <TeamMember>() // TODO: get all members for this team }; return(View(viewModel)); } // no matching team found :( return(View()); }
public async Task <ActionResult> EditTeamDetails(TeamDetailsViewModel model) { try { var result = await TeamServiceClient.EditTeamDetails(model.Id, model.TeamDetails.TeamName, model.TeamDetails.PublicPrice, model.TeamDetails.PrivatePrice, model.TeamDetails.CurrencyId); model.TeamDetails = await TeamServiceClient.GetTeamDetailsForEdit(model.Id); return(RedirectToAction("DetalisTeam", "Team", new { id = model.TeamDetails.TeamId })); } catch (Exception e) { ViewBag.Message = e.Message; } return(View()); }
public async Task <ActionResult> DetailsTeam(long id) { var model = new TeamDetailsViewModel(); try { model.TeamDetailsList = await TeamServiceClient.GetTeamDetails(id); model.TeamName = model.TeamDetailsList[0].TeamName; } catch (Exception e) { ViewBag.Message = e.Message; } return(View(model)); }
public async Task <IActionResult> Details(string id) { if (id == null) { throw new ApplicationException($"Passed ID parameter is absent."); } var team = await _teamService.FindAsync(id); if (team == null) { throw new ApplicationException($"Unable to find team with ID '{id}'."); } var model = new TeamDetailsViewModel(team); return(View(model)); }
public TeamDetailsViewModel GetTeamDetails(int teamId) { var team = this.teamRepository.GetById(teamId); var teamDetails = new TeamDetailsViewModel(); if (team != null) { teamDetails.Name = team.Name; teamDetails.Alias = team.Alias; teamDetails.Captain = team.Captain; teamDetails.Division = team.Division; teamDetails.Established = team.Established; teamDetails.Region = team.Region; teamDetails.Trophies = team.Trophies ?? 0; } return(teamDetails); }
public async Task <ActionResult> AddNewTeam(TeamDetailsViewModel newTeam) { if (newTeam.TeamName != null) { var userEmail = Session["User"].ToString(); try { await TeamServiceClient.AddNewTeam(newTeam.TeamName, "0", "0", 1, userEmail); return(RedirectToAction("TeamList", "Team")); } catch (Exception e) { ViewBag.Message = "Hiba történt a csapat hozzáadás során!"; } } return(View()); }
public async Task <IActionResult> Details(int id) { if (!await this.teams.ContainsAsync(id)) { return(NotFound()); } var formModel = new TeamDetailsViewModel { Team = await this.teams.DetailsAsync(id) }; if (User.Identity.IsAuthenticated) { var userId = this.userManager.GetUserId(User); formModel.UserIsInTeam = await this.teams.HasPlayerAsync(id, userId); } return(View(formModel)); }
private async Task <ViewResult> TeamDetailsView(TeamModel teamModel) { if (user.role.name == "CEO") { List <UserModel> users = await _context.Users.Include(u => u.team).Include(u => u.role).Where(u => u.team == null).ToListAsync(); TeamDetailsViewModel tdvm = new TeamDetailsViewModel(teamModel, users); return(View("Details", tdvm)); } else if (user.role.name == "Team Lead" && user.leadedTeam == teamModel) { List <UserModel> users = await _context.Users.Include(u => u.team).Include(u => u.role).Where(u => u.team == null).ToListAsync(); TeamDetailsViewModel tdvm = new TeamDetailsViewModel(teamModel, users); return(View("DetailsTeamLead", tdvm)); } else { return(View("DetailsNormalUser", teamModel)); } }
private TeamProductsViewModel TeamProductsViewModel(int id, int currentPage, int maxPage, string actionName, TeamDetailsViewModel teamDetailsViewModel) { var pageViewModel = new PagesViewModel() { CurrentPage = currentPage, MaxPage = maxPage, AreaName = "", ActionName = actionName, ControllerName = controllerName, RouteId = id, }; var teams = this.GetAllTeams(); return(new TeamProductsViewModel() { Teams = teams, TeamWithProducts = teamDetailsViewModel, Page = pageViewModel }); }
public IActionResult Details(int id) { Team currTeam = _repositiry.GetTeamById(id); if (currTeam != null) { var allPlayers = _repositiry.GetPersons(); var detailsViewModel = new TeamDetailsViewModel() { Id = currTeam.Id, Name = currTeam.Name, teamPlayers = allPlayers.Where(p => p.Team == currTeam), unassignedPlayers = allPlayers.Where(p => p.Team == null) }; return(View(detailsViewModel)); } else { return(RedirectToAction("TeamsList")); } }
public async Task <ActionResult> EditTeam(int id) { var team = new TeamDetailsResponseDto(); var teamView = new TeamDetailsViewModel(); try { teamView.CurrencyList = await AdminServiceClient.GetAllCurrency(); var dd = await TeamServiceClient.GetTeamById(id); teamView.TeamName = dd.Name; teamView.Id = dd.Id; teamView.PrivatePrice = team.PrivatePrice; teamView.PublicPrice = team.PublicPrice; } catch (Exception e) { ViewBag.Message = e.Message; } return(View(teamView)); }
private TeamDetailsViewModel CreateModel(dynamic team) { var model = new TeamDetailsViewModel(); model.LogoUrl = team.LogoId; model.Name = team.Name; var products = new List <ProductIndexViewModel>(); foreach (var product in team.Products) { products.Add(new ProductIndexViewModel { Id = product.Id, Title = product.Title, Price = product.Price, Discount = product.Discount, PictureUrl = product.PictureUrl }); } model.Products = products; return(model); }
public async Task <ActionResult> Create(TeamDetailsViewModel teamViewModel, IFormFile logoPath) { try { if (ModelState.IsValid) { teamViewModel.CaptainId = (await _userManager.GetUserAsync(User)).PlayerId; teamViewModel.LogoPath = await logoPath.SaveImage(_hostEnvironment.WebRootPath, ImgPath); var team = _mapper.Map <Team>(teamViewModel); await _teamService.AddAsync(team); await _teamService.AddPlayerToTeam(teamViewModel.CaptainId, team.Id); return(RedirectToAction(nameof(Index))); } return(View(teamViewModel)); } catch { return(View(teamViewModel)); } }