/// <summary> /// Opening Page for Entering New Recipes /// </summary> public async Task <IActionResult> Add() { ViewData["Title"] = _localizer["PageTitleAdd"]; ViewData["PageDesc"] = _localizer["PageDescAdd"]; var getCategoriesQuery = _queryFactory.CreateCategoriesQuery(); var cList = await getCategoriesQuery.ExecuteAsync().ConfigureAwait(false); var getVarietiesQuery = _queryFactory.CreateVarietiesQuery(); var vList = await getVarietiesQuery.ExecuteAsync().ConfigureAwait(false); var getYeastQuery = _yeastQueryFactory.CreateYeastsQuery(); var yList = await getYeastQuery.ExecuteAsync().ConfigureAwait(false); var batchTempQuery = _journalQueryFactory.CreateBatchTempUOMQuery(); var uomTempList = await batchTempQuery.ExecuteAsync().ConfigureAwait(false); var batchSugarQuery = _journalQueryFactory.CreateBatchSugarUOMQuery(); var uomSugarList = await batchSugarQuery.ExecuteAsync().ConfigureAwait(false); var addRecipeModel = _modelFactory.CreateAddRecipeModel(cList, vList, yList, uomSugarList, uomTempList); addRecipeModel.User = await UserManagerAgent.GetUserAsync(User).ConfigureAwait(false); return(View(addRecipeModel)); }
public async Task <IActionResult> Add() { ViewData["Title"] = _localizer["PageTitleAdd"]; ViewData["PageDesc"] = _localizer["PageDescAdd"]; var batchTempQuery = _journalQueryFactory.CreateBatchTempUOMQuery(); var uomTempList = await batchTempQuery.ExecuteAsync().ConfigureAwait(false); var batchSugarQuery = _journalQueryFactory.CreateBatchSugarUOMQuery(); var uomSugarList = await batchSugarQuery.ExecuteAsync().ConfigureAwait(false); var batchVolumeQuery = _journalQueryFactory.CreateBatchVolumeUOMQuery(); var uomVolumeList = await batchVolumeQuery.ExecuteAsync().ConfigureAwait(false); var getCategoriesQuery = _recipeQueryFactory.CreateCategoriesQuery(); var cList = await getCategoriesQuery.ExecuteAsync().ConfigureAwait(false); var varietiesQuery = _recipeQueryFactory.CreateVarietiesQuery(); var vList = await varietiesQuery.ExecuteAsync().ConfigureAwait(false); var getYeastQuery = _yeastQueryFactory.CreateYeastsQuery(); var yList = await getYeastQuery.ExecuteAsync().ConfigureAwait(false); var addBatchModel = _modelFactory.CreateBatchViewModel(null, null, vList, cList, yList, null, uomVolumeList, uomSugarList, uomTempList); // validate with User (ApplicationUser) var appUser = await UserManagerAgent.GetUserAsync(User).ConfigureAwait(false); addBatchModel.BatchJwt = await CreateJwtTokenAsync(appUser, 15).ConfigureAwait(false); return(View(addBatchModel)); }
public async Task <IActionResult> Index() { ViewData["Title"] = _localizer["PageTitle"]; ViewData["PageDesc"] = _localizer["PageDesc"]; var getCategoriesQuery = _queryRecipeFactory.CreateCategoriesQuery(); var cList = await getCategoriesQuery.ExecuteAsync().ConfigureAwait(false); var getVarietiesQuery = _queryRecipeFactory.CreateVarietiesQuery(); var vList = await getVarietiesQuery.ExecuteAsync().ConfigureAwait(false); var getYeastsQuery = _queryYeastFactory.CreateYeastsQuery(); var yeastsDto = await getYeastsQuery.ExecuteAsync().ConfigureAwait(false); var yeastsModel = _modelFactory.CreateYeastModel(cList, vList, yeastsDto); return(View(yeastsModel)); }
public Factory(Business.Recipe.Queries.IFactory recipeQueryFactory, Business.Yeast.Queries.IFactory yeastQueryFactory, Business.MaloCulture.Queries.IFactory maloQueryFactory, Business.Journal.Queries.IFactory journalQueryFactory) { _recipeQueryFactory = recipeQueryFactory ?? throw new ArgumentNullException(nameof(recipeQueryFactory)); _yeastQueryFactory = yeastQueryFactory ?? throw new ArgumentNullException(nameof(yeastQueryFactory)); _journalQueryFactory = journalQueryFactory ?? throw new ArgumentNullException(nameof(journalQueryFactory)); _maloQueryFactory = maloQueryFactory ?? throw new ArgumentNullException(nameof(maloQueryFactory)); _getCategoriesQuery = _recipeQueryFactory.CreateCategoriesQuery(); _getVarietiesQuery = _recipeQueryFactory.CreateVarietiesQuery(); _getYeastsQuery = _yeastQueryFactory.CreateYeastsQuery(); _getYeastPairsQuery = _yeastQueryFactory.CreateYeastPairQuery(); _getYeastBrandsQuery = _yeastQueryFactory.CreateBrandsQuery(); _getYeastStylesQuery = _yeastQueryFactory.CreateStylesQuery(); _getMaloQuery = _maloQueryFactory.CreateMaloCulturesQuery(); _getMaloBrandsQuery = _maloQueryFactory.CreateBrandsQuery(); _getMaloStylesQuery = _maloQueryFactory.CreateStylesQuery(); _getSugarUOMQuery = _journalQueryFactory.CreateBatchSugarUOMQuery(); _getTempUOMQuery = _journalQueryFactory.CreateBatchTempUOMQuery(); _getVolumeUOMQuery = _journalQueryFactory.CreateBatchVolumeUOMQuery(); _categoriesDtoList = _getCategoriesQuery.Execute(); _varietiesDtoList = _getVarietiesQuery.Execute(); _yeastsDtoList = _getYeastsQuery.Execute(); _yeastPairingsDtoList = _getYeastPairsQuery.Execute(); _yeastBrandsDtoList = _getYeastBrandsQuery.Execute(); _yeastStylesDtoList = _getMaloStylesQuery.Execute(); _maloDtoList = _getMaloQuery.Execute(); _maloBrandsDtoList = _getMaloBrandsQuery.Execute(); _maloStylesDtoList = _getYeastStylesQuery.Execute(); _getSugarUomList = _getSugarUOMQuery.Execute(); _getTempUomList = _getTempUOMQuery.Execute(); _getVolumeUomList = _getVolumeUOMQuery.Execute(); }
public async Task <IActionResult> Index(string id) { ViewData["Title"] = _localizer["PageTitle"]; ViewData["PageDesc"] = _localizer["PageDesc"]; var getYeastQuery = _yeastQueryFactory.CreateYeastsQuery(); var getYeastPairs = _yeastQueryFactory.CreateYeastPairQuery(); var getCategoriesQuery = _recipeQueryFactory.CreateCategoriesQuery(); var getVarietiesQuery = _recipeQueryFactory.CreateVarietiesQuery(); var getRecipesQuery = _recipeQueryFactory.CreateRecipesQuery(); var getMaloCulturesQuery = _maloQueryFactory.CreateMaloCulturesQuery(); var getJournalsQuery = _journalQueryFactory.CreateBatchesQuery(); // using TPL to parallel call gets List <Task> tasks = new List <Task>(); var categoryTask = Task.Run(async() => await getCategoriesQuery.ExecuteAsync().ConfigureAwait(false)); tasks.Add(categoryTask); var cList = await categoryTask.ConfigureAwait(false); var varietyTask = Task.Run(async() => await getVarietiesQuery.ExecuteAsync().ConfigureAwait(false)); tasks.Add(varietyTask); var vList = await varietyTask.ConfigureAwait(false); var yeastTask = Task.Run(async() => await getYeastQuery.ExecuteAsync().ConfigureAwait(false)); tasks.Add(yeastTask); var yList = await yeastTask.ConfigureAwait(false); var pairsTask = Task.Run(async() => await getYeastPairs.ExecuteAsync().ConfigureAwait(false)); tasks.Add(pairsTask); var ypList = await pairsTask.ConfigureAwait(false); var recipeTask = Task.Run(async() => await getRecipesQuery.ExecuteAsync().ConfigureAwait(false)); tasks.Add(recipeTask); var rList = await recipeTask.ConfigureAwait(false); var maloTask = Task.Run(async() => await getMaloCulturesQuery.ExecuteAsync().ConfigureAwait(false)); tasks.Add(maloTask); var mList = await maloTask.ConfigureAwait(false); var journalTask = Task.Run(async() => await getJournalsQuery.ExecuteAsync().ConfigureAwait(false)); tasks.Add(journalTask); var jList = await journalTask.ConfigureAwait(false); Task.WaitAll(tasks.ToArray()); // build model var model = _modelFactory.CreateAdminModel(id); // make sure admin security role exist if (!await RoleManagerAgent.RoleExistsAsync(_appSettings.SecRole.Admin).ConfigureAwait(false)) { ApplicationRole role = new ApplicationRole { Name = _appSettings.SecRole.Admin, Description = "Perform all operations." }; IdentityResult roleResult = await RoleManagerAgent.CreateAsync(role).ConfigureAwait(false); if (!roleResult.Succeeded) { ModelState.AddModelError(string.Empty, "Error while creating role!"); return(View(model)); } } // gather users data var users = UserManagerAgent.Users.ToList(); var userVms = _mapper.Map <List <UserViewModel> >(users); model.UsersViewModel.Users.Clear(); model.UsersViewModel.Users.AddRange(userVms); foreach (var user in model.UsersViewModel.Users) { user.IsAdmin = await UserManagerAgent.IsInRoleAsync(user, _appSettings.SecRole.Admin).ConfigureAwait(false); user.IsLockedOut = await UserManagerAgent.IsLockedOutAsync(user).ConfigureAwait(false); } // gather roles data var roles = await RoleManagerAgent.Roles.OrderBy(r => r.Name).ToListAsync().ConfigureAwait(false); var roleVms = _mapper.Map <List <RoleViewModel> >(roles); model.RolesViewModel.Roles.Clear(); model.RolesViewModel.Roles.AddRange(roleVms); // gather category / variety data model.CategoriesViewModel.Categories.Clear(); model.CategoriesViewModel.Categories.AddRange(_modelFactory.CreateCategoryViewModel(cList)); model.VarietiesViewModel.Varieties.Clear(); model.VarietiesViewModel.Varieties.AddRange(_modelFactory.CreateVarietyViewModel(vList)); // gather yeast data model.YeastsViewModel.Yeasts.Clear(); model.YeastsViewModel.Yeasts.AddRange(_modelFactory.CreateYeastViewModel(yList)); // gather malolactic data model.MaloCulturesViewModel.Cultures.Clear(); model.MaloCulturesViewModel.Cultures.AddRange(_modelFactory.CreateMaloCultureViewModel(mList)); // gather recipe data model.RecipesViewModel.Recipes.Clear(); model.RecipesViewModel.Recipes.AddRange(_modelFactory.CreateRecipeViewModel(rList)); // gather journal data model.JournalsViewModel.Journals.Clear(); model.JournalsViewModel.Journals.AddRange(_modelFactory.CreateJournalViewModel(jList, userVms)); return(View(model)); }