// // GET: /Draft/Details/5 public ActionResult Details(int id) { DraftViewModel dvm = GetDraftViewModel(id); if (dvm == null) { return(RedirectToAction("Index")); } var member = GetAuthorizedMember(); if (member != null) { using (var sl = new SystemLogic()) { dvm.IsMemberOfDraft = sl.IsMemberOfDraft(member.Id, id); } } if (Request.IsAjaxRequest()) { return(Json(dvm, JsonRequestBehavior.AllowGet)); } return(View(dvm)); }
public ActionResult Pick(string cardName, int draftId) { var authMember = GetAuthorizedMember(); using (var sl = new SystemLogic()) { if (!sl.IsMemberOfDraft(authMember.Id, draftId)) { return(RedirectToAction("Index")); } var draftLogic = GetDraftLogic.FromDraftId(draftId); var card = sl.GetCard(cardName); if (card == null) { var likeList = sl.FindCard(cardName); return(Json(new { pickresult = false, reason = "Card was not found!", alternatives = likeList })); } var pickSuccess = draftLogic.PickCard(draftId, authMember.Id, card.Id); if (!pickSuccess) { return(Json(new { pickresult = false, reason = "Card was already picked, try another card!" })); } DraftViewModel dvm = GetDraftViewModel(draftId); return(Json(new { pickresult = true, updatedDvm = dvm })); } }
//GET: FantasyLeagues/Draft/5 public async Task <IActionResult> Draft(int?id) { if (id == null) { return(NotFound()); } if (!_service.DraftExists(id.Value)) { await _service.CreateDraft(id.Value); DraftViewModel viewModel = new DraftViewModel() { Draft = await _service.GetDraft(id.Value), AvailablePlayers = new SelectList(await _service.GetDraftPlayers(id.Value), "Value", "Text"), Team = await _mService.GetTeamByOwnerID(User.FindFirst(ClaimTypes.NameIdentifier).Value) }; return(View(viewModel)); } else { DraftViewModel viewModel = new DraftViewModel() { Draft = await _service.GetDraft(id.Value), AvailablePlayers = new SelectList(await _service.GetDraftPlayers(id.Value), "Value", "Text"), Team = await _mService.GetTeamByOwnerID(User.FindFirst(ClaimTypes.NameIdentifier).Value) }; return(View(viewModel)); } }
public async Task <IActionResult> MakeSoloDraft() { var champion = await this.championService.GetRandomChampionAsync(); var build = await this.itemService.GetRandomBuildAsync(); var position = await this.positionService.GetRandomPositionAsync(); var summonerSpells = await this.summonerSpellService.GetRandomSummonerSpellsAsync(); if (PositionConstants.Jungle.Equals(position.Name)) { build = await this.itemService.GetRandomJungleBuildAsync(); summonerSpells = await this.summonerSpellService.GetJunglerSummonerSpellsAsync(); } else if (PositionConstants.Support.Equals(position.Name)) { build = await this.itemService.GetRandomSupportBuildAsync(); } var draftViewModel = new DraftViewModel() { Champion = champion, Build = build, Position = position, SummonerSpells = summonerSpells }; return(this.View(draftViewModel)); }
public async Task <IActionResult> SaveDraft([FromBody] DraftViewModel model) { var command = new SaveDraftCommand { UserId = HttpContext.GetLoggedUserId(), Content = model.Content, QuestionId = model.QuestionId }; var response = await _mediator.Send(command); return(Ok(BaseResponse.Ok(response.Message))); }
public ActionResult Index() { DraftViewModel model = null; try { DraftUser user = DraftAuthentication.AuthenticateRequest(HttpContext.Request); model = new DraftViewModel(user); } catch (DraftAuthenticationException) { return(RedirectToAction("Index", "Login")); } return(View(model)); }
public async Task ThenViewIsReturned( [Frozen] Mock <IModelMapper> modelMapper, CohortsByAccountRequest request, DraftViewModel viewModel, CohortController controller) { modelMapper .Setup(x => x.Map <DraftViewModel>(request)) .ReturnsAsync(viewModel); var result = await controller.Draft(request) as ViewResult; Assert.NotNull(result); Assert.AreEqual(result.Model, viewModel); }
public WhenGettingCohortsFixture() { Request = new CohortsByProviderRequest(); ModelMapperMock = new Mock <IModelMapper>(); CohortsViewModel = new CohortsViewModel(); ReviewViewModel = new ReviewViewModel(); DraftViewModel = new DraftViewModel(); WithTransferSenderViewModel = new WithTransferSenderViewModel(); ModelMapperMock.Setup(x => x.Map <CohortsViewModel>(Request)).ReturnsAsync(CohortsViewModel); ModelMapperMock.Setup(x => x.Map <ReviewViewModel>(Request)).ReturnsAsync(ReviewViewModel); ModelMapperMock.Setup(x => x.Map <DraftViewModel>(Request)).ReturnsAsync(DraftViewModel); ModelMapperMock.Setup(x => x.Map <WithTransferSenderViewModel>(Request)).ReturnsAsync(WithTransferSenderViewModel); Sut = new CohortController(Mock.Of <IMediator>(), ModelMapperMock.Object, Mock.Of <ILinkGenerator>(), Mock.Of <ICommitmentsApiClient>()); }
public IActionResult Draft(int id) { DraftViewModel draftViewModel = new DraftViewModel(); var userId = _userManager.GetUserId(User); Draft draft = _draftService.GetDraft(id); Team userTeam = _teamService.GetUserTeam(draft); Team availablePlayers = _teamService.GetAvailablePlayers(draft); draftViewModel.LeagueName = draft.LeagueName; draftViewModel.TeamName = userTeam.TeamName; draftViewModel.DraftPosition = draft.UserDraftPosition; draftViewModel.NumberOfTeams = draft.NumberOfTeams; draftViewModel.MyPlayers = userTeam.Players.ToHashSet(); draftViewModel.AvailablePlayers = availablePlayers.Players.ToHashSet(); int pick = _draftService.GetPick(draft); draftViewModel.pick = pick; draftViewModel.round = _draftService.GetRound(pick, draft.NumberOfTeams); return(View(draftViewModel)); }
private DraftViewModel GetDraftViewModel(int draftId) { var draftLogic = GetDraftLogic.FromDraftId(draftId); var systemLogic = new SystemLogic(); if (!draftLogic.IsDraftAvailable(draftId)) { return(null); } var draft = systemLogic.GetDraftById(draftId); using (var sl = new SystemLogic()) { var picks = systemLogic.GetPickList(draftId); var dvm = new DraftViewModel { Id = draftId, MaximumNumberOfPicks = draft.MaximumPicksPerMember, Name = draft.Name, Owner = sl.GetMember(draft.Owner.Id).FullName, CreationDate = draft.CreatedDate, CurrentPickPosition = draftLogic.CurrentPickPosition(draftId), CurrentNumberOfPicks = picks.Count }; var members = systemLogic.GetDraftMembers(draftId); foreach (var draftMemberPositions in members) { var member = sl.GetMember(draftMemberPositions.Member.Id); var draftMemberVm = new DraftMemberVm { DisplayName = member.FullName, Id = member.Id, }; dvm.Members.Add(draftMemberVm); } var pickCount = picks.Count; var startIndex = pickCount - draft.DraftSize; if (startIndex < 0) { startIndex = 0; } for (int i = startIndex; i < pickCount; i++) { var pick = picks[i]; var member = sl.GetMember(pick.Member.Id); var card = sl.GetCard(pick.Card.Id); var pvm = new PickViewModel { CardId = pick.Card.Id, MemberId = pick.Member.Id, PickTime = PickTime.History, CardName = card.Name, MemberName = member.FullName }; dvm.Picks.Add(pvm); } var currentPick = new PickViewModel() { MemberId = draft.CurrentTurn.Id, MemberName = sl.GetMember(draft.CurrentTurn.Id).FullName, PickTime = PickTime.Current, }; dvm.Picks.Add(currentPick); for (int i = 0; i < draft.DraftSize; i++) { var nextDraftPosition = draftLogic.GetNextPickPosition(pickCount + 1 + i, draft.DraftSize); var nextMember = dvm.Members[nextDraftPosition - 1]; var nextPick = new PickViewModel { MemberName = nextMember.DisplayName, MemberId = nextMember.Id, PickTime = PickTime.Future }; dvm.Picks.Add(nextPick); } var authMember = GetAuthorizedMember(); if (authMember != null) { foreach (FuturePick fp in sl.GetMyFuturePicks(draftId, authMember.Id)) { Card card = sl.GetCard(fp.Card.Id); dvm.FuturePicks.Add(card.Name); } } return(dvm); } }
public ActionResult New() { DraftViewModel model = new DraftViewModel(); return(View(model)); }
public async Task <WhenMappingDraftRequestToViewModelFixture> Map() { DraftViewModel = await Mapper.Map(DraftRequest); return(this); }
public WhenMappingDraftRequestToViewModelFixture Map() { DraftViewModel = Mapper.Map(DraftRequest).Result; return(this); }