public GetAllStaticDataViewModel(IEnumerable <GetUserDecksWithHeapsAndTags.ResultModel> userDecks, IEnumerable <GetAllAvailableTags.ViewModel> allTags, IEnumerable <GetUsers.ViewModel> allUsers, IStringLocalizer <SearchController> localizer, IStringLocalizer <DecksController> decksControllerLocalizer, MemCheckUser?currentUser) { UserDecks = new[] { new GetAllStaticDataDeckViewModel(Guid.Empty, localizer["Ignore"].Value) } .Concat(userDecks.Select(applicationResult => new GetAllStaticDataDeckViewModel(applicationResult, localizer, decksControllerLocalizer))); AllDecksForAddingCards = userDecks.Select(applicationResult => new GetAllStaticDataDeckForAddViewModel(applicationResult.DeckId, applicationResult.Description)); AllApplicableTags = allTags.Select(tag => new GetAllStaticDataTagViewModel(tag.TagId, tag.Name)); AllRequirableTags = new[] { new GetAllStaticDataTagViewModel(noTagFakeGuid, localizer["None"].Value) } .Concat(allTags.Select(tag => new GetAllStaticDataTagViewModel(tag.TagId, tag.Name))); AllExcludableTags = new[] { new GetAllStaticDataTagViewModel(noTagFakeGuid, localizer["None"].Value), new GetAllStaticDataTagViewModel(allTagsFakeGuid, localizer["All"].Value) } .Concat(allTags.Select(tag => new GetAllStaticDataTagViewModel(tag.TagId, tag.Name))); AllUsers = new[] { new GetAllStaticDataUserViewModel(Guid.Empty, localizer["Any"].Value) } .Concat(allUsers.Select(user => new GetAllStaticDataUserViewModel(user.UserId, user.UserName))); LocalizedText = new GetAllStaticDataLocalizedTextViewModel(localizer); PossibleHeapsForMove = Enumerable.Range(0, MoveCardToHeap.MaxTargetHeapId).Select(heapId => new GetAllStaticDataHeapViewModel(heapId, DisplayServices.HeapName(heapId, decksControllerLocalizer))); CurrentUserId = currentUser == null ? Guid.Empty : currentUser.Id; ShowDebugInfo = DisplayServices.ShowDebugInfo(currentUser); }
public async Task <IActionResult> UserDecks() { try { var user = await userManager.GetUserAsync(HttpContext.User); var userId = (user == null) ? Guid.Empty : user.Id; var decks = new GetUserDecksWithTags(dbContext).Run(userId); var result = decks.Select(deck => new UserDecksViewModel(deck.DeckId, deck.Description, DisplayServices.ShowDebugInfo(user), deck.Tags, localizer)); return(base.Ok(result)); } catch (Exception e) { return(ControllerError.BadRequest(e, this)); } }