public GetAllStaticDataDeckViewModel(GetUserDecksWithHeapsAndTags.ResultModel applicationResult, IStringLocalizer <SearchController> localizer, IStringLocalizer <DecksController> decksControllerLocalizer) { DeckId = applicationResult.DeckId; DeckName = applicationResult.Description; Heaps = new[] { new GetAllStaticDataHeapViewModel(-1, localizer["Any"].Value) } .Concat(applicationResult.Heaps.OrderBy(heap => heap).Select(heap => new GetAllStaticDataHeapViewModel(heap, DisplayServices.HeapName(heap, decksControllerLocalizer)))); RequirableTags = new[] { new GetAllStaticDataTagViewModel(noTagFakeGuid, localizer["None"].Value) } .Concat(applicationResult.Tags.Select(tag => new GetAllStaticDataTagViewModel(tag.TagId, tag.TagName))); ExcludableTags = new[] { new GetAllStaticDataTagViewModel(noTagFakeGuid, localizer["None"].Value), new GetAllStaticDataTagViewModel(allTagsFakeGuid, localizer["All"].Value) } .Concat(applicationResult.Tags.Select(tag => new GetAllStaticDataTagViewModel(tag.TagId, tag.TagName))); }
public async Task <IActionResult> GetAllStaticData() { var user = await userManager.GetUserAsync(HttpContext.User); IEnumerable <GetUserDecksWithHeapsAndTags.ResultModel> decksWithHeapsAndTags; if (user == null) { decksWithHeapsAndTags = new GetUserDecksWithHeapsAndTags.ResultModel[0]; } else { decksWithHeapsAndTags = await new GetUserDecksWithHeapsAndTags(dbContext).RunAsync(user.Id); } var allTags = new GetAllAvailableTags(dbContext).Run(); var allUsers = new GetUsers(dbContext).Run(); GetAllStaticDataViewModel value = new GetAllStaticDataViewModel(decksWithHeapsAndTags, allTags, allUsers, localizer, decksControllerLocalizer, user); return(base.Ok(value)); }