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> OnPost() { if (!ModelState.IsValid) { return(Page()); } if (Plant.PlantId > 0) { await _plantData.UpdatePlant(Plant); } else { var id = await _plantData.InsertPlant(Plant); } TempData["Message"] = $"{Plant.Name} has been saved."; return(RedirectToPage("./List")); }