public IActionResult Reserve() { var cart = HttpContext.Session.Get <List <CartItem> >("Cart"); ReserveMedItemsViewModel viewModel = new ReserveMedItemsViewModel() { Items = cart }; return(View(viewModel)); }
public async Task <IActionResult> Reserve(ReserveMedItemsViewModel viewModel) { var cart = HttpContext.Session.Get <List <CartItem> >("Cart"); if (!ModelState.IsValid) { return(View(new ReserveMedItemsViewModel() { Items = cart })); } var nowDateTime = DateTime.Now.ToString("yyyyMMdd HH:mm:ss"); foreach (var item in cart) { await _context.Database.ExecuteSqlRawAsync($"EXEC reserve_med_item '{nowDateTime}', {item.MedicalItemId}, {item.PharmacyId}, {item.Count}, '{viewModel.Telephone}'"); } ClearCart(); return(RedirectToAction("Index", "ReservedMedItems")); }