public async Task <IActionResult> Create(Consumer consumer) { if (ModelState.IsValid) { var userId = this.User.FindFirstValue(ClaimTypes.NameIdentifier); consumer.IdentityUserId = userId; var consumerWithLogLat = await _geocodingService.GetGeoCoding(consumer); _context.Add(consumerWithLogLat); _repo.Save(); return(RedirectToAction(nameof(Index))); } return(View("details", consumer)); }
public async Task <IActionResult> Create(Models.Customer customer, int productId) { try { var userId = User.FindFirstValue(ClaimTypes.NameIdentifier); customer.IdentityUserId = userId; var custromerwithLatLng = await _geocoding.GetGeoCoding(customer); _context.Customers.Add(customer); _context.SaveChanges(); return(RedirectToAction(nameof(Index))); } catch (Exception e) { Console.WriteLine(e); return(View()); } //ViewBag.Products = new SelectList(product.Name, "Name", "Name"); }
public async Task <ActionResult> CreateProfile(Customer customer) { try { var userId = this.User.FindFirstValue(ClaimTypes.NameIdentifier); customer.IdentityUserId = userId; customer = ChargeCustomer(customer, _recurringCharge); customer = await _geocoding.GetGeoCoding(customer); _dbContext.Customers.Add(customer); _dbContext.SaveChanges(); return(RedirectToAction(nameof(Details /*change me later*/))); } catch { return(View()); } }