コード例 #1
0
        /// <summary>
        /// determines Orders processing-state
        /// </summary>
        /// <param name="orderIdentifier"></param>
        /// <returns></returns>



        public ViewModels.OrderViewModel AddOrder(List <ViewModels.OrderItemViewModel> items, ViewModels.UserDataViewModel customerUser, ViewModels.UserDataViewModel storeUser)
        {
            var Order = new Models.OrderModel()
            {
                OrderState      = Enums.EnumOrderState.ClientPlacedOrder,
                OrderType       = Enums.EnumOrderType.Default,
                OrderIdentifier = Guid.NewGuid().ToString(),
                CustomerUser    = userContext.GetUser(customerUser.Id),
                StoreUser       = userContext.GetUser(storeUser.Id)
            };

            Order.Items = new List <Models.OrderItemModel>();
            foreach (var item in items)
            {
                Order.Items.Add(new Models.OrderItemModel()
                {
                    PartNo = item.PartNumber,
                    Price  = item.Price,
                    Name   = item.Name,
                    Amount = item.Amount,
                });
            }

            Order.OrderIdentifier = Guid.NewGuid().ToString();
            var newObj = orderContext.AddOrUpdateOrder(Order);

            return(newObj.ToOrderViewModel());
        }
コード例 #2
0
        public static ViewModels.OrderViewModel ToOrderViewModel(this Models.OrderModel model)
        {
            if (model == null)
            {
                return(null);
            }

            var vm = new ViewModels.OrderViewModel()
            {
                CustomerUser = model.CustomerUser != null?model.CustomerUser.ToUserDataViewModel() : new UserDataViewModel(),
                                   StoreUser = model.StoreUser != null?model.StoreUser.ToUserDataViewModel() : new UserDataViewModel(),
                                                   OrderIdentifier = model.OrderIdentifier,
                                                   OrderState      = model.OrderState,
                                                   OrderType       = model.OrderType,
                                                   CreationDate    = model.CreationDate,
                                                   PaymentState    = model.PaymentState,
                                                   ShippingState   = model.ShippingState,
                                                   Items           = new List <OrderItemViewModel>()
            };

            foreach (var item in model.Items)
            {
                vm.Items.Add(item.ToOrderItemViewModel());
            }
            return(vm);
        }
コード例 #3
0
        public void OrderPase()
        {
            Orders.Clear();

            var htmldoc = new HtmlAgilityPack.HtmlDocument();

            htmldoc.LoadHtml(OrderHtml);
            var nodea = htmldoc.DocumentNode.SelectNodes("//table//tr/td[@class='details']/a[1]");

            if (nodea != null && nodea.Any())
            {
                foreach (var item in nodea)
                {
                    var orderModel = new Models.OrderModel();
                    orderModel.DetailLink = System.IO.Path.Combine(OrderLink, item.GetAttributeValue("href", "").Trim());
                    orderModel.DetailNum  = item.InnerText.Trim();
                    this.Orders.Add(orderModel);
                }
            }

            var asinNode = htmldoc.DocumentNode.SelectSingleNode("/html/body/div[4]/div[2]/table/tbody/tr/td[5]/p[1]");

            if (asinNode != null)
            {
                this.Asin = asinNode.InnerText;
            }
        }
コード例 #4
0
        public ActionResult UserPreview(Models.OrderModel order)
        {
            //show what the stats are
            ViewData["count"] = HttpContext.Session.GetInt32("pizzacount");
            //find out what our cost is at, in string form for some reason i can't explain
            HttpContext.Session.GetString("pizzacost");
            ViewData["cost"] = HttpContext.Session.GetString("pizzacost");

            //attempt to push pizza to the database.
            //first create new pizza order
            PizzaOrder finalpizza = new PizzaOrder();

            //obtain value for pizzacounter
            int pizzacounter = (int)HttpContext.Session.GetInt32("pizzacounter");

            //loop through all my sessions that are storing my pizza objects
            //make pizza objects and add them to my order and pizzatable.
            for (int i = 0; i < pizzacounter; i++)
            {
                //intialize temppizzastring
                string temppizzastring = "";
                temppizzastring = HttpContext.Session.GetString($"pizzastring{i + 1}");
                Pizza mypiz = new Pizza();
                mypiz = mypiz.recreatePizza(temppizzastring);
                finalpizza.addPizza(mypiz);
            }

            //add current location to pizzaorder so it doesn't break my sql query
            finalpizza.LocationAddress = HttpContext.Session.GetString("location");

            //make a pizzauser cause its an input for my database add method.
            PizzaUser pizuser = new PizzaUser();

            pizuser.username = HttpContext.Session.GetString("username");

            bool didorderwork = false;

            if (PC.CheckOrderConditions(finalpizza.LocationAddress, pizuser.username))
            {
                didorderwork = PC.AddPizzaOrder(finalpizza, pizuser);
            }
            else
            {
                didorderwork = false;
            }


            if (didorderwork)
            {
                //finally try to add the thing to the database
                ViewData["isOrdervalid"] = "Order is valid";
                return(RedirectToAction("login", "user", order));
            }
            else
            {
                ViewData["isOrdervalid"] = "Order is invalid";
                return(View());
            }
        }
コード例 #5
0
        public ActionResult OrderResult(Models.OrderModel MyModel)
        {
            if (MyModel == null)
            {
                return(new EmptyResult());
            }
            string resultString = "<p>Запрос на сервер Косого переулка был получен " + DateTime.Now + "</p>" + "<p>ФИО заказчика: " + MyModel.FullName + "</p>"
                                  + "<p>Адрес почтового ящика: " + MyModel.OrderMail + "</p>" + "<p>Список покупок:</p>";
            string MyCookie = Request.Cookies["order"].Value;

            string[] masProducts = MyCookie.Split('&');
            u0263406_shopBaseEntities context = new u0263406_shopBaseEntities();
            int            tempId;
            List <string>  purchaseList        = new List <string>();
            List <PRODUCT> purchaseListProduct = new List <PRODUCT>();
            PRODUCT        tempProduct;
            bool           tempConvert;

            if (masProducts.Length != 0)
            {
                foreach (string str in masProducts)
                {
                    tempConvert = Int32.TryParse(str.ToString(), out tempId);
                    if (tempConvert)
                    {
                        tempProduct = context.PRODUCT.Where(c => c.PRODUCT_ID == tempId).ToList().FirstOrDefault();
                        if (tempProduct != null)
                        {
                            resultString += "<p>" + tempProduct.PRODUCT_NAME + "</p>";
                            purchaseListProduct.Add(tempProduct);
                        }
                    }
                }
            }
            decimal sum = 0;

            foreach (PRODUCT pr in purchaseListProduct)
            {
                sum += pr.PRODUCT_PRICE;
            }
            string sumString = Convert.ToString(sum);

            resultString += "Общая сумма: " + sumString + " галеонов";
            MvcHtmlString mvcString = new MvcHtmlString(resultString);

            ViewBag.ResultString = mvcString;
            return(View());
        }
コード例 #6
0
        public ActionResult SaveOrder(Models.OrderModel orderModel)
        {
            try
            {
                List <OrderDetailsModel> orderDetailsModels = new List <OrderDetailsModel>();
                var models = this.ShopServices.GetShopCart();
                if (models.Count() == 0)
                {
                    throw new Exception();
                }

                foreach (var item in models)
                {
                    var newModel = new OrderDetailsModel()
                    {
                        Item  = item.ProdName,
                        Count = (int)item.Count,
                        Price = item.Price,
                    };
                    orderDetailsModels.Add(newModel);
                }


                using (var db = new EF.DBContext())
                {
                    orderModel.OrderDate         = DateTime.Now;
                    orderModel.Amount            = this.ShopServices.ProdAmount;
                    orderModel.OrderDetailModels = orderDetailsModels;
                    db.Orders.Add(orderModel);
                    db.SaveChanges();
                }

                var c = new HttpCookie("shopcart")
                {
                    Expires = DateTime.Now.AddDays(-1)
                };
                Response.Cookies.Add(c);

                ViewData["Message"] = "訂購成功。";
            }
            catch (Exception ex)
            {
                ViewData["Message"] = $"訂購失敗。({ex.Message})";
            }

            return(View());
        }
コード例 #7
0
ファイル: OrderContext.cs プロジェクト: womd/SignalRService
 public Models.OrderModel AddOrUpdateOrder(Models.OrderModel model)
 {
     Models.OrderModel dbmodel;
     if (model.ID == 0)
     {
         dbmodel = _db.Orders.Add(model);
     }
     else
     {
         dbmodel = _db.Orders.FirstOrDefault(ln => ln.ID == model.ID);
         dbmodel.CustomerUser    = model.CustomerUser;
         dbmodel.StoreUser       = model.StoreUser;
         dbmodel.OrderIdentifier = model.OrderIdentifier;
         dbmodel.OrderState      = model.OrderState;
         dbmodel.OrderType       = model.OrderType;
         dbmodel.Items           = model.Items;
     }
     _db.SaveChanges();
     return(dbmodel);
 }
コード例 #8
0
        // GET: Order/Edit/5
        public ActionResult Edit(int id)
        {
            Models.OrderModel orderModel = orderRepository.GetOrderByID(id);

            var orderViewModel = new OrderViewModel();

            orderViewModel.Order           = orderModel;
            orderViewModel.InitialStatusID = orderModel.StatusID;

            var shop = shopRepository.GetShopByID(orderModel.ShopID);

            orderViewModel.ShopName = shop.Name;

            var customer = customerRepository.GetCustomerById(orderModel.CustomerID);

            orderViewModel.CustomerName = customer.FirstName + " " + customer.LastName;

            var        statuses   = statusRepository.GetAllStatuses();
            SelectList statusList = new SelectList(statuses, "StatusID", "Name");

            ViewData["StatusList"] = statusList;

            var orderProducts = orderProductsRepository.GetOrderProductsByOrderId(id);

            List <ProductModel> products = new List <ProductModel>();

            foreach (var orderProduct in orderProducts)
            {
                var product = productRepository.GetProductById(orderProduct.ProductID);
                products.Add(product);
            }

            orderViewModel.Products = products;

            return(View("EditOrder", orderViewModel));
        }
コード例 #9
0
        public ActionResult PlaceOrder(IFormCollection collection, Models.OrderModel ordermodel)
        {
            try
            {
                var or = db.GetOrders();

                pizza = new Pizza();

                pizza.CustID = TempData["custID"] as string;
                TempData.Keep();

                ordermodel.CustID = TempData["custID"] as string;
                TempData.Keep();

                if (pizza.CustID == "-1")
                {
                    ViewData["text"] = "Please Log In to place your order.";
                    return(View());
                }

                pizza.Location = ordermodel.Location;
                pizza.Size     = ordermodel.Size;
                pizza.Crust    = ordermodel.Crust;
                pizza.Topping1 = ordermodel.Topping1;
                pizza.Topping2 = ordermodel.Topping2;
                pizza.Topping3 = ordermodel.Topping3;
                pizza.Topping4 = ordermodel.Topping4;
                pizza.Topping5 = ordermodel.Topping5;
                pizza.Qty      = ordermodel.Qty;

                pizza.Subtotal = pizza.CalculateSubtotal();

                foreach (var i in or)
                {
                    if (pizza.CustID == i.CustID)
                    {
                        if (pizza.CheckIfEligible2Hours(i.Time, i.Date) == false)
                        {
                            ViewData["Text"] = "Please wait 2 hours after ordering to place another order.";
                            return(View());
                        }
                        if (pizza.CheckIfEligibleSameDay(i.Date, i.Location) == false)
                        {
                            ViewData["Text"] = "You can only order at one location per day.";
                            return(View());
                        }
                    }
                }

                if (pizza.CheckIfOverAmount() == false)
                {
                    ViewData["Text"] = "Your order cannot exceed over $1000.";
                    return(View());
                }

                TempData["location"] = pizza.Location;
                TempData["size"]     = pizza.Size;
                TempData["crust"]    = pizza.Crust;
                TempData["top1"]     = pizza.Topping1;
                TempData["top2"]     = pizza.Topping2;
                TempData["top3"]     = pizza.Topping3;
                TempData["top4"]     = pizza.Topping4;
                TempData["top5"]     = pizza.Topping5;
                TempData["qty"]      = Convert.ToString(pizza.Qty);
                TempData["subtotal"] = Convert.ToString(pizza.Subtotal);

                return(RedirectToAction("ConfirmOrder"));
            }
            catch
            {
                ViewData["Text"] = "Could not submit order.";
                return(View());
            }
        }
コード例 #10
0
 public ActionResult PlaceOrder()
 {
     om = new OrderModel(); //test to see if necessary
     return(View());
 }
コード例 #11
0
 // POST: api/Orders
 public string Post(Models.OrderModel value)
 {
     return("Done!");
 }
コード例 #12
0
        public ActionResult AddOrder(Models.OrderModel ordermodel)
        {
            if (ModelState.IsValid)
            {
                Order order = new Order();
                order.CustomerID = ordermodel.CustomerID;
                order.EmployeeID = ordermodel.EmployeeID;
                order.Status     = OrderStatus.Shipped;

                if (!string.IsNullOrEmpty(ordermodel.ShippedDate))
                {
                    order.ShippedDate = new DateTime(int.Parse(ordermodel.OrderDate.Substring(6, 4)),
                                                     int.Parse(ordermodel.OrderDate.Substring(0, 2)),
                                                     int.Parse(ordermodel.OrderDate.Substring(3, 2)));
                }
                else
                {
                    order.Status = OrderStatus.NotShipped;
                }

                if (!string.IsNullOrEmpty(ordermodel.OrderDate))
                {
                    order.OrderDate = new DateTime(int.Parse(ordermodel.OrderDate.Substring(6, 4)),
                                                   int.Parse(ordermodel.OrderDate.Substring(0, 2)),
                                                   int.Parse(ordermodel.OrderDate.Substring(3, 2)));
                }

                if (!string.IsNullOrEmpty(ordermodel.RequiredDate))
                {
                    order.RequiredDate = new DateTime(int.Parse(ordermodel.OrderDate.Substring(6, 4)),
                                                      int.Parse(ordermodel.OrderDate.Substring(0, 2)),
                                                      int.Parse(ordermodel.OrderDate.Substring(3, 2)));
                }
                else
                {
                    order.Status = OrderStatus.New;
                }

                order.ShipVia        = ordermodel.ShipVia;
                order.Freight        = ordermodel.Freight;
                order.ShipName       = ordermodel.ShipName;
                order.ShipAddress    = ordermodel.ShipAddress;
                order.ShipCity       = ordermodel.ShipCity;
                order.ShipCountry    = ordermodel.ShipCountry;
                order.ShipRegion     = ordermodel.ShipRegion;
                order.ShipPostalCode = ordermodel.ShipPostalCode;

                try
                {
                    return(RedirectToAction("FullInfo", "Home", new { id = Logic.AddOrderNoDetails(order) }));
                }
                catch (ArgumentException e)
                {
                    ModelState.AddModelError(e.ParamName, "Несуществующий идендификатор.");
                    return(View(ordermodel));
                }
            }
            else
            {
                return(View(ordermodel));
            }
        }