Ejemplo n.º 1
0
 public ActionResult Create(OrderModel order)
 {
     if (ModelState.IsValid)
     {
         _IOrder.AddOrder(order);
         return(RedirectToAction("Index"));
     }
     ViewBag.ProductTypeID = new SelectList(db.ProductTypes, "TypeName", "TypeName");
     return(View(order));
 }
Ejemplo n.º 2
0
        public IActionResult OnPost(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            StorageModel = _storage.GetWhiskyById(id);

            if (StorageModel != null)
            {
                if (StorageModel.Available > 0)
                {
                    StorageModel.Available--;
                    StorageModel.Reserved++;
                    _storage.UpdateWhiskyByModel(StorageModel);

                    OrderModel orderModel = new OrderModel();
                    orderModel.Completed = false;
                    orderModel.Customer  = _user.GetUserByName(User.Identity.Name);
                    orderModel.Whisky    = StorageModel.Whisky;

                    _order.AddOrder(orderModel);
                }
            }

            return(RedirectToPage("./Index"));
        }
Ejemplo n.º 3
0
        public IActionResult CreateOrder(string CartId)
        {
            //var cartId = model.ShoppingCart.ShoppingCartId;
            var   cartElements = _order.GetShoppingCartItemsToOrder(CartId);
            Order order        = new Order()
            {
                OrderNumber = _order.NextNumber(),
                OrderedDate = DateTime.Now,
                Status      = "Utworzono"
            };

            _order.AddOrder(order);

            //int OrderId = _order.GetLastId();
            foreach (var item in cartElements)
            {
                OrderLine orderLine = new OrderLine()
                {
                    Amount  = item.Amount,
                    Price   = item.product.Price,
                    Note    = item.Note,
                    Product = item.product,
                    Order   = order
                };
                _order.AddLine(orderLine);
            }
            _order.CalculateOrderTotalPrice(order.Id);
            return(RedirectToAction("FulfillAddress", "Address", new { OrderId = order.Id }));
            //return RedirectToAction("FulfillAddress", "Address");
        }
Ejemplo n.º 4
0
        public IActionResult BuyProduct(int productId, int sizeId, int colorId, int quantityNumber)
        {
            string userNumber = User.FindFirst(ClaimTypes.Email)?.Value;

            _orderService.AddOrder(productId, userNumber, sizeId, colorId, quantityNumber);
            Sms.SendSms("09372796350", "افزودن به سبد خرید ." + userNumber);

            return(Redirect("/UserPanel"));
        }
Ejemplo n.º 5
0
 public IActionResult CreateOrder(Order order)
 {
     order.Lines = GetCart().Selections.Select(s => new OrderLine
     {
         ProductId = s.ProductId,
         Quantity  = s.Quantity
     }).ToArray();
     _orderService.AddOrder(order);
     SaveCart(new Cart());
     return(RedirectToAction(nameof(Completed)));
 }
Ejemplo n.º 6
0
        public HttpResponseMessage AddAnOrder([FromBody] Order_DataAccessLayer.Model.Order order)
        {
            Order_DataAccessLayer.Model.Order addAnOrder = new Order_DataAccessLayer.Model.Order()
            {
                Amount     = order.Amount,
                VAT        = order.VAT,
                CustomerId = order.CustomerId                 // can be extracted from a seesion variable of a logged in user
            };
            _order.AddOrder(addAnOrder);

            return(new HttpResponseMessage(HttpStatusCode.Created));
        }
Ejemplo n.º 7
0
 public IActionResult AddOrUpdateOrder(Order order)
 {
     order.Lines = order.Lines
                   .Where(l => l.Id > 0 || (l.Id == 0 && l.Quantity > 0)).ToArray();
     if (order.Id == 0)
     {
         _orderService.AddOrder(order);
     }
     else
     {
         _orderService.UpdateOrder(order);
     }
     return(RedirectToAction(nameof(Index)));
 }
Ejemplo n.º 8
0
 public IActionResult NewOrder(OrderModel model)
 {
     if (!ModelState.IsValid)
     {
         ViewData["cart"] = cart.ItemList;
         return(View(new OrderModel()));
     }
     model.Products = new List <ProductStringified>(cart.ItemList.Select(x =>
                                                                         new ProductStringified {
         ProductName = x.Product.Name, ProductQuantity = x.Quantity
     }));
     orderManager.AddOrder(model);
     cart.Clear();
     return(Redirect("/Order/Thanks"));
 }
Ejemplo n.º 9
0
        public async Task AddOrder(Badge badge)
        {
            var Order    = new Order();
            var OrderDtl = new OrderDetails();
            var sugar    = new Sugar(drinkOrder.Quantity);

            Order.Badge = badge;
            await order.AddOrder(Order);

            OrderDtl.Drink = await drinks.GetDrinkById(drinkOrder.DrinkId);

            OrderDtl.Mug = drinkOrder.Mug;
            sugar.Add(OrderDtl);

            await orderDetail.Add(OrderDtl, Order.Badge.Id);
        }
Ejemplo n.º 10
0
        public AddOrderResponse addOrder(Order order, DateTime orderDate)
        {
            AddOrderResponse response = new AddOrderResponse();

            response.order = _orderRepo.AddOrder(order, orderDate);

            if (response.order == null)
            {
                response.Success = false;
                response.Message = "Order cannot be added. Please try again";
                return(response);
            }
            else
            {
                response.Success = true;
            }
            return(response);
        }
Ejemplo n.º 11
0
        public void AddOrder_ShouldFail()
        {
            // Arrange
            int     orderId    = 21;
            int     customerId = 6;
            var     amount     = 50;
            decimal vat        = new decimal(0.15);
            var     orderDTO   = new Order_DataAccessLayer.Model.Order
            {
                OrderId    = orderId,
                Amount     = amount,
                CustomerId = customerId,
                VAT        = vat
            };

            _orderMock.Setup(x => x.AddOrder(orderDTO)).Verifiable();

            // Act
            Order_DataAccessLayer.Model.Order result = _orderContext.AddOrder(orderDTO);

            // Assert
            Assert.Equal(expected: result, orderDTO);
        }
Ejemplo n.º 12
0
 public IActionResult AddOrder(AddNewOrderModel addNewOrderModel)
 {
     try
     {
         if (ModelState.IsValid)
         {
             var     uniquePONumber = iOrder.GetAllUniquePoNumber();
             var     uniqueOrderIds = iOrder.GetAllUniqueInvoiceIds();
             long    promoCodeId    = 0;
             decimal percentage     = 0;
             decimal discountAmount = 0;
             if (!string.IsNullOrWhiteSpace(addNewOrderModel.Promocode))
             {
                 var promocodeModel = iPromoCode.GetPromoCodeByCode(addNewOrderModel.Promocode);
                 if (promocodeModel != null)
                 {
                     promoCodeId    = promocodeModel.PromoCodeId;
                     percentage     = promocodeModel.Percentage;
                     discountAmount = promocodeModel.Amount;
                 }
             }
             Order orderModel = OrderHelper.BindOrderModel(addNewOrderModel, uniquePONumber, uniqueOrderIds, promoCodeId, percentage, discountAmount);
             List <OrderDetail> detailModel = OrderHelper.BindOrderDetailModel(addNewOrderModel.ProductDetail);
             long orderId = 0;
             if (orderModel.OrderId <= 0)
             {
                 orderId = iOrder.AddOrder(orderModel, detailModel);
             }
             else
             {
                 orderId = iOrder.EditOrder(orderModel, detailModel);
             }
             if (orderId > 0)
             {
                 var cart             = iCart.EmptyCart(DBHelper.ParseInt64(addNewOrderModel.UserId));
                 var orderDetailModel = iOrder.GetOrderDetail(orderId);
                 if (!string.IsNullOrWhiteSpace(addNewOrderModel.IsMailSend) && addNewOrderModel.IsMailSend.Equals("1"))
                 {
                     if (orderDetailModel != null)
                     {
                         var              HostingPath         = env.ContentRootPath;
                         string           clientEmail         = config.GetValue <string>("app_settings:ClientEmail");
                         string           clientEmailPassword = config.GetValue <string>("app_settings:ClientEmailPassword");
                         string           port             = config.GetValue <string>("app_settings:Port");
                         string           mailHost         = config.GetValue <string>("app_settings:SMTPURL");
                         string           host             = this.Request.Host.Value;
                         string           scheme           = this.Request.Scheme;
                         OrderDetailModel orderDetailmodel = OrderHelper.BindOrderDetailModel(orderDetailModel, null);
                         OrderHelper.SendResetPasswordMail(orderDetailmodel.EmailId, orderDetailmodel, DBHelper.ParseString(HostingPath), clientEmail, clientEmailPassword, port, mailHost, host, scheme);
                     }
                 }
                 return(Ok(ResponseHelper.Success(MessageConstants.OrderPlaced + orderDetailModel[0].Order.UniqueOrderId)));
             }
             else
             {
                 return(Ok(ResponseHelper.Error(MessageConstants.OrderNotPlaced)));
             }
         }
         else
         {
             return(Ok(ResponseHelper.Error(MessageConstants.CompulsoryData)));
         }
     }
     catch (Exception ex)
     {
         LogHelper.ExceptionLog(ex.Message + "  :::::  " + ex.StackTrace);
         return(Ok(ResponseHelper.Error(ex.Message)));
     }
 }
Ejemplo n.º 13
0
 public static int AddOrder(OrderInfo order)
 {
     order.ID = dal.AddOrder(order);
     return(order.ID);
 }
Ejemplo n.º 14
0
 public async Task Post([FromBody] Order order)
 {
     await orders.AddOrder(order);
 }
Ejemplo n.º 15
0
 public ActionResult <TOrder> Post(TOrder order)
 {
     _order.AddOrder(order);
     return(Ok());
 }
Ejemplo n.º 16
0
 public string AddOrder(int Klantid, int Verkoperid, int Productid, int quantity)
 {
     return(context.AddOrder(Klantid, Verkoperid, Productid, quantity));
 }
Ejemplo n.º 17
0
        public IActionResult AddOrder(Models.Order customerorder)
        {
            int orderid = _userrepo.AddOrder(customerorder);

            return(Ok(orderid));
        }