Ejemplo n.º 1
0
        public void CancelStockAndOrder(Order order, ref HopeLingerieEntities context)
        {
            if (stockValidate == null)
                return;

            order.OrderStatusId = 2; //estado de orden cancelada.
              //  hopeLingerieEntities.SaveChanges();

            foreach (var orderDetail in order.OrderDetails)
            {
                var productId = orderDetail.ProductId;
                var colorId = orderDetail.ColorId;
                var sizeId = orderDetail.SizeId;
                var quantity = orderDetail.Quantity;

                var stock = context.Stocks.SingleOrDefault(x => x.ProductId == productId && x.ColorId == colorId && x.SizeId == sizeId && x.Active);

                if (stock != null)
                {
                    stockValidate.AddStock(stock, quantity);
                }
            }

              //  hopeLingerieEntities.SaveChanges();
        }
 /// <summary>
 /// Deprecated Method for adding a new object to the Orders EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToOrders(Order order)
 {
     base.AddObject("Orders", order);
 }
Ejemplo n.º 3
0
        public virtual ActionResult OrderUpdate(int Id)
        {
            ViewData["OrderStatus"] = hopeLingerieEntities.OrderStatus1.OrderBy(x => x.Description).Where(x => x.Active).ToList();
            ViewData["Products"] = hopeLingerieEntities.Products.OrderBy(x => x.ProductId).ToList();

            var nullProduct = new Product();
            nullProduct.Code = "-- Seleccionar --";
            nullProduct.ProductId = 0;

            ((List<Product>)ViewData["Products"]).Insert(0, nullProduct);

            if (Id > 0)
            {
                var order = hopeLingerieEntities.Orders.SingleOrDefault(a => a.OrderId == Id && a.Active);

                Session["OrderID"] = order.OrderId;

                if (order.CouponId.HasValue)
                {
                    var coupon = hopeLingerieEntities.Coupons.SingleOrDefault(x => x.CouponId == order.CouponId);
                    ViewData["Coupon"] = coupon.Code;
                }
                else
                    ViewData["Coupon"] = string.Empty;

                ViewData["Discount"] = Convert.ToDecimal(order.Discount) / 100;
                return View(order);
            }

            var newCustomer = new Customer();
            var newOrder = new Order();
            newOrder.OrderStatusId = 1;
            newOrder.Customer = newCustomer;

            return View(newOrder);
        }
 /// <summary>
 /// Create a new Order object.
 /// </summary>
 /// <param name="orderId">Initial value of the OrderId property.</param>
 /// <param name="customerId">Initial value of the CustomerId property.</param>
 /// <param name="discount">Initial value of the Discount property.</param>
 /// <param name="daysShipping">Initial value of the DaysShipping property.</param>
 /// <param name="orderStatusId">Initial value of the OrderStatusId property.</param>
 /// <param name="addedDate">Initial value of the AddedDate property.</param>
 /// <param name="deliveryStatusId">Initial value of the DeliveryStatusId property.</param>
 public static Order CreateOrder(global::System.Int32 orderId, global::System.Int32 customerId, global::System.Int32 discount, global::System.Int32 daysShipping, global::System.Int32 orderStatusId, global::System.DateTime addedDate, global::System.Int32 deliveryStatusId)
 {
     Order order = new Order();
     order.OrderId = orderId;
     order.CustomerId = customerId;
     order.Discount = discount;
     order.DaysShipping = daysShipping;
     order.OrderStatusId = orderStatusId;
     order.AddedDate = addedDate;
     order.DeliveryStatusId = deliveryStatusId;
     return order;
 }