Ejemplo n.º 1
0
        public IActionResult Reserve()
        {
            var cart = HttpContext.Session.Get <List <CartItem> >("Cart");

            ReserveMedItemsViewModel viewModel = new ReserveMedItemsViewModel()
            {
                Items = cart
            };

            return(View(viewModel));
        }
Ejemplo n.º 2
0
        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"));
        }