public void OnGet() { if (SearchTerm == null) { Plants = _plantData.GetPlants().GetAwaiter().GetResult(); } else { PlantVM.Name = SearchTerm; Plants = _plantData.GetPlants(PlantVM).GetAwaiter().GetResult(); } //DbPlants = plantData.GetPlantList(ConvertVMToPersistance(PlantVM)).GetAwaiter().GetResult(); //Plants = ConvertPersistanceToVM(DbPlants); }
/// <summary> /// Get all the departments from db /// </summary> /// <returns></returns> public async Task <List <DepartmentVM> > GetDepartments() { //PlantData plantData = new PlantData(_db, _adapter); List <DepartmentVM> departments = _adapter .ConvertToTListFromU <DepartmentVM, DepartmentModel>(await GetDepartmentList()); PlantVM plant = new PlantVM(); foreach (var item in departments) { plant.PlantId = item.PlantId; item.Plant = _plantData.GetPlants(plant).GetAwaiter().GetResult().FirstOrDefault(); } return(departments); }
public async Task Run() { //List<string> emailAddresses = _config.GetSection("EmailAddresses").Get<List<string>>(); //foreach (string emailAddress in emailAddresses) //{ // _loggerFactory.LogInformation("Email address: {@EmailAddress}", emailAddress); //} var plantVM = new PlantVM(); //plantVM.Name = "Bla bla"; try { var id = await _plantData.InsertPlant(plantVM); } catch (System.Exception ex) { _loggerFactory.LogWarning("{Message}", ex.Message); } var result = await _plantData.GetPlants(plantVM); foreach (var item in result) { _loggerFactory.LogInformation("{1}-{2}-{3}-{4}-{5}-{6}", item.PlantId, item.Name, item.Address, item.City, item.Email, item.Phone); } }
public async Task <IActionResult> OnGet(int?departmentId) { PlantsList = _plantData.GetPlants() .GetAwaiter().GetResult().Select(a => new SelectListItem { Value = a.PlantId.ToString(), Text = a.Name }); if (departmentId.HasValue) { Department.DepartmentId = departmentId.Value; var dep = await _departmentData.GetDepartments(Department); Department = dep.FirstOrDefault(); } else { Department = new DepartmentVM(); } if (Department == null) { return(RedirectToPage("./NotFound")); } return(Page()); }
public async Task <IActionResult> OnGet(int plantId) { Plant.PlantId = plantId; var plant = await _plantData.GetPlants(Plant); Plant = plant.FirstOrDefault(); if (Plant == null) { return(RedirectToPage("./NotFound")); } return(Page()); }
public async Task <IActionResult> OnGet(int?plantId) { if (plantId.HasValue) { Plant.PlantId = plantId.Value; var plant = await _plantData.GetPlants(Plant); Plant = plant.FirstOrDefault(); } else { Plant = new PlantVM(); } if (Plant == null) { return(RedirectToPage("./NotFound")); } return(Page()); }