コード例 #1
0
 public IActionResult Create(Order model)
 {
     Order order = m_orderData.Add(model);
     // redirect to the view so that the user won't resubmit a POST request once the view loads for them
     return RedirectToAction(nameof(Details), new { id = order.Id });
     // this is why RedirectToAction is used, rather than just returning a View
 }
コード例 #2
0
ファイル: OrderController.cs プロジェクト: JABueser/bartender
        public IActionResult Create(Drink model)
        {
            var newOrder = new Order();

            newOrder.isDone      = false;
            newOrder.DrinkName   = model.Name;
            newOrder.DrinkId     = model.Id;
            newOrder.TimeOrdered = DateTime.Now;

            newOrder = _orderData.Add(newOrder);

            return(RedirectToAction("Index", "Drink"));
        }
コード例 #3
0
        public async Task <IActionResult> OnPostRelizeOrder()
        {
            LoggedUser = await userManager.GetUserAsync(User);

            UserData        = memberData.GetMemberById(LoggedUser.Id);
            UserData.Basket = memberData.GetAllBasketItems(UserData.Id).ToList();

            SetListsBasedOnBasket(UserData.Basket);

            if (BasketItems.Count > 0)
            {
                //Creation of new order
                var order = new Order();
                //Timestamp
                order.Time = DateTime.Now;
                //Setting a member id of whom the order belong to
                order.MemberId = UserData.Id;
                //Setting order.Products to products that are in basket list.
                order.Products = OrderedProducts(BasketItems);

                foreach (var orderedProduct in order.Products)
                {
                    order.Cost += productData.GetById(orderedProduct.ProductId).Price;
                }

                //Setting products from user basket to unavailable to make them impossible to buy twice or add to another basket
                productService.SetProductsUnavailable(BasketItems);

                //Adding data into DB
                orderData.Add(order);
                orderData.Commit();

                TempData["Message"] = "Order placed";
            }
            else
            {
                TempData["Message"] = "Order cannot be placed";
            }

            return(RedirectToPage("./Basket"));
        }
コード例 #4
0
ファイル: ActionHelper.cs プロジェクト: taliars/DocManager
        public async Task <Order> CreateNewOrderAsync()
        {
            var ensure = await inputAffirm("Новый заказ", "Введите номер заказа");

            if (string.IsNullOrEmpty(ensure))
            {
                return(null);
            }

            var order = new Order
            {
                ObjectData = new ObjectData
                {
                    Name = ensure
                }
            };

            await Task.Run(() => orderData.Add(order));

            return(order);
        }