public async Task <IActionResult> CheckoutAsync(Data.Models.Order order, double Lat, double Lng) { if (shoppingCart.IsEmpty) { ModelState.AddModelError("CartItems", "Shopping Cart Empty.."); } var deliveryAreas = restaurant.GetDeliveryAreasByResturantId(shoppingCart.ResturantId); var list = new List <string>(); foreach (var area in Enum.GetValues <DeliveryAreas>()) { if (deliveryAreas.HasFlag(area)) { list.Add(area.ToString()); } } order.Address.Area = Regex.Replace(order.Address.Area, @"\s+", ""); if (!list.Contains(order.Address.Area)) { ModelState.AddModelError("Area", "Area out of coverage"); } var user = await userManager.Users.Include(U => U.Addresses).SingleOrDefaultAsync(U => U.UserName == User.Identity.Name); if (ModelState.IsValid) { if (order.Address.ID == 0) //Save new address { user.Addresses.Add(order.Address); } // save for upcoming requests TempData["Order"] = JsonSerializer.Serialize(order); //order; TempData["LocalRedirect"] = true; return(RedirectToAction("Pay")); } var orderToPlace = new Data.Models.Order() { FirstName = user.FirstName, LastName = user.LastName, Email = user.Email }; var checkoutVM = new CheckoutViewModel() { Order = orderToPlace, Addresses = user.Addresses, Lat = Lat, Lng = Lng, showMap = 1 }; return(View()); }