Пример #1
0
 //---------------------------------------------------------------------
 public OrderViewModel(Order order)
 {
     this.TimeStamp = order.DateTime;
     this.SerialNumber = order.SerialNumber;
     this.OrderModel = order;
     orderItemsCollection=new ObservableCollection<OrderItemViewModel>();
 }
Пример #2
0
    private void List()
    {
        PagerItem pagerItem = new PagerItem();

        pagerItem.CurrentPage = 1;
        pagerItem.PageSize    = 15;
        pagerItem.Keywords    = "";

        IList list  = _orderBLL.Select(pagerItem);
        int   count = list.Count;

        StringBuilder result = new StringBuilder();

        result.Append("{result:[");
        if (count > 0)
        {
            for (int i = 0; i < count; i++)
            {
                Model.Order order = (Model.Order)list[i];
                result.Append("{OrderID:\"").Append(order.ID).Append("\",");
                result.Append("CustomID:\"").Append(order.CustomID).Append("\",");
                result.Append("Status:\"").Append(order.Status).Append("\",");
                result.Append("CreateTime:\"").Append(order.CreateTime).Append("\"}");
                if (i < count - 1)
                {
                    result.Append(",");
                }
            }
        }

        result.Append("]}");

        Response.Write(result.ToString());
        Response.End();
    }
Пример #3
0
        public void Should_accept_a_value_with_valid_characters()
        {
            var order = new Order {OrderId = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"};

            List<Violation> violations = _validator.Validate(order).ToList();
            Assert.AreEqual(0, violations.Count);
        }
Пример #4
0
        static void Main(string[] args)
        {
            using(var salesUnitOfWork = new SalesUnitOfWork("Sales"))
            {
                var customer = new Customer { FirstName = "John", LastName = "Smith" };

                var order = new Order {Date = DateTime.Now};
                order.OrderItems.Add(new OrderItem {Price = 101});

                customer.Orders.Add(order);

                salesUnitOfWork.Customers.Add(customer);

                salesUnitOfWork.Commit();

                var customers = salesUnitOfWork.Customers
                    .FindAll()
                    .Include("Orders.OrderItems")
                    .Where(c => c.Orders.Any(o => o.OrderItems.Any(oi => oi.Price > 100)))
                    .OrderBy(c => c.FirstName)
                    .Take(10)
                    .ToList();

                foreach (var c in customers)
                {
                    System.Console.WriteLine(c.FirstName);
                    foreach (var o in c.Orders)
                    {
                        System.Console.WriteLine(o.Date);
                    }
                }

            }
        }
Пример #5
0
 public async Task SaveOrder(Order order)
 {
     IMongoClient _client = new MongoClient("mongodb://localhost:27017/");
     IMongoDatabase _database = _client.GetDatabase("cqrs-akka-nodejs");
     var collection = _database.GetCollection<Order>("orders");
     await collection.InsertOneAsync(order);
 }
        public void after_the_dsl_is_configured_order_cannot_be_null()
        {
            var order = new Order();
            var dsl = new ShoppingCartScriptEngine(order);

            Assert.IsNotNull(dsl.Order);
        }
        public void dsl_order_ammount_should_be_equal()
        {
            var order = new Order();
            var dsl = new ShoppingCartScriptEngine(order);

            Assert.AreEqual(dsl.OrderAmmountIs, order.TotalAmmount);
        }
Пример #8
0
        public void Should_not_violate_a_valid_string()
        {
            var order = new Order {OrderId = "a"};

            List<Violation> violations = _validator.Validate(order).ToList();
            Assert.AreEqual(0, violations.Count);
        }
Пример #9
0
        public void Should_not_match_a_value_with_invalid_characters()
        {
            var order = new Order {OrderId = "123"};

            List<Violation> violations = _validator.Validate(order).ToList();
            Assert.AreEqual(1, violations.Count);
            Assert.AreEqual("did not contain: LMNOP", violations[0].Message);
        }
        public ShoppingCartScriptEngine(Order order)
        {
            if (order == null)
                throw new ArgumentNullException("order", "cannot be null");

            Order = order;
            _engine = new ScriptEngine();
        }
Пример #11
0
        public void Should_accept_a_valid_customer_value()
        {
            var order = new Order {Customer = new Customer {Name = "a"}};

            List<Violation> violations = _validator.Validate(order).ToList();

            Assert.AreEqual(0, violations.Count);
        }
Пример #12
0
        public void Should_fail_with_a_null_value()
        {
            var order = new Order();

            List<Violation> violations = _validator.Validate(order).ToList();
            Assert.AreEqual(1, violations.Count);
            Assert.AreEqual("did not end with: XYZ", violations[0].Message);
        }
Пример #13
0
        public void Should_fail_with_a_null_value()
        {
            var order = new Order();

            List<Violation> violations = _validator.Validate(order).ToList();
            Assert.AreEqual(1, violations.Count);
            Assert.AreEqual("did not match expression: ^[a-zA-Z]{1,40}$", violations[0].Message);
        }
Пример #14
0
        public void Should_not_match_a_value_with_invalid_characters()
        {
            var order = new Order {OrderId = "DEX20101001001"};

            List<Violation> violations = _validator.Validate(order).ToList();
            Assert.AreEqual(1, violations.Count);
            Assert.AreEqual("did not match expression: ^[a-zA-Z]{1,40}$", violations[0].Message);
        }
Пример #15
0
        public void Should_support_not_null()
        {
            var order = new Order {OrderId = null};

            List<Violation> violations = _validator.Validate(order).ToList();
            Assert.AreEqual(1, violations.Count);
            Assert.AreEqual("cannot be null", violations[0].Message);
        }
Пример #16
0
        public void Should_pass_a_valid_object()
        {
            var order = new Order();
            order.Items = new List<OrderItem>();
            order.Items.Add(new OrderItem());

            List<Violation> violations = _validator.Validate(order).ToList();

            Assert.AreEqual(0, violations.Count);
        }
Пример #17
0
        //[Route("GetOrders")]
        public List <Model.Order> GetOrders()
        {
            var user  = new User("Elisheva", "Epstein", "*****@*****.**");
            var order = new Model.Order(DateTime.Now, user);
            var lst   = new List <Model.Order> {
                order
            };

            return(lst);
        }
Пример #18
0
        public void Should_catch_the_null_property()
        {
            var order = new Order();

            List<Violation> violations = _validator.Validate(order).ToList();

            Assert.AreEqual(1, violations.Count);
            Assert.AreEqual("cannot be null", violations[0].Message);
            Assert.AreEqual("Order.Customer", violations[0].Key);
            Assert.AreEqual("Order.Customer cannot be null", violations[0].ToString());
        }
Пример #19
0
        public void Should_pass_with_no_conditions()
        {
            var order = new Order();

            List<Violation> violations = _validator.Validate(order).ToList();

            Assert.AreEqual(1, violations.Count);
            Assert.AreEqual("must be within the past 1 year, 2 months, 1 week, 3 days", violations[0].Message);
            Assert.AreEqual("Order.OrderDate", violations[0].Key);
            Assert.AreEqual("Order.OrderDate must be within the past 1 year, 2 months, 1 week, 3 days", violations[0].ToString());
        }
Пример #20
0
        public void Should_catch_an_empty_collection()
        {
            var order = new Order();
            order.Items = new List<OrderItem>();

            List<Violation> violations = _validator.Validate(order).ToList();

            Assert.AreEqual(1, violations.Count);
            Assert.AreEqual("cannot be empty", violations[0].Message);
            Assert.AreEqual("Order.Items", violations[0].Key);
            Assert.AreEqual("Order.Items cannot be empty", violations[0].ToString());
        }
Пример #21
0
        public static List<Order> GetOrderList(string url)
        {

            List<Order> completeOrder = new List<Order>();

            try
            {
                JObject json = NetworkUtil.GetJson(url);
                JArray orderArray = (JArray)json["orders"];

                foreach (JObject orderArrayItem in orderArray)
                {
                    Order orderitem = new Order();
                    List<Product> productList = new List<Product>();
                    orderitem.OrderID = (int)orderArrayItem["id"];

                    if(!OrderHolder.IsOrderUnique(orderitem.OrderID))
                    {
                        Console.WriteLine("Dropped " + orderitem.OrderID);
                        continue;
                    }

                    orderitem.TableNumber = (string)orderArrayItem["tableNumber"];
                    orderitem.DateTime = (string)orderArrayItem["dateTime"];
                    orderitem.TotalPrice = (double)orderArrayItem["totalPrice"];
                    JArray orders = (JArray)orderArrayItem["orderedProducts"];

                    foreach (JObject order in orders)
                    {

                        Product product = new Product();
                        JObject orderDTO = (JObject)order["productDTO"];
                        product.Name = (string)orderDTO["name"];
                        product.Price = (double)orderDTO["price"];
                        product.Attributes = (string)order["attributes"];
                        product.Quantity = (int)order["quantity"];
                        product.Notes = (string)order["notes"];
                        productList.Add(product);

                    }
                    orderitem.Products = productList;
                    OrderHolder.AddOrder(orderitem);
                    completeOrder.Add(orderitem);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error while parsing json" + ex.Message);
                return null;
            }
            return completeOrder;
        }
Пример #22
0
        public OrderChargeModel Calculate(Order order)
        {
            var orderItems = (from c in _orderItem where c.OrderId == order.OrderId select c).ToList();
            if (orderItems.Any())
            {
                _orderCharge = new OrderChargeModel();
                var firstOrderItem = orderItems.FirstOrDefault();
                if (firstOrderItem != null) _orderCharge.CookerId = firstOrderItem.CookerId;
                var taxPercent = new Common.Util().GetTaxPercent(_orderCharge.CookerId);
                _orderCharge.OrderTypeValue = Enum.GetName(typeof(OrderModelType.Values), order.OrderTypeId);
                _orderCharge.PaymentMethodValue = Enum.GetName(typeof(PaymentMethodType.Values), order.PaymentMethodId);

                #region PickUpOrderCharge

                if (order.OrderTypeId == (int)OrderType.Values.PickUp)
                {
                    _orderCharge = PickUpCharge(order, taxPercent);
                }

                #endregion

                #region DeliveryOrderCharge

                var cookerDelieryZonesId = (from c in _cookerDeliveryZones where c.CookerId == _orderCharge.CookerId select c.DeliveryId).ToList();

                decimal deliveryFees = 0;
                foreach (var deliveryZoneId in cookerDelieryZonesId)
                {
                    //Custom KML Function to see if the item is in the zone
                    //Moq for now
                    var deliveryzone = _deliveryZones.FirstOrDefault(c => c.DeliveryId == deliveryZoneId);

                    //KML integration to see if deliveryaddress is Zone
                    if (_deliveryAddress.AddressTypeId == (int)AddressToDeliveryZone.Values.AddressInZone)
                    {
                        if (deliveryzone != null)
                        {
                            deliveryFees = deliveryzone.DeliveryFees;
                        }
                    }
                }

                _orderCharge = DeliveryCharge(order, deliveryFees, taxPercent);

                #endregion

                _orderCharge.SalesTaxes = new Money().RoundTo2Decimal(CalculateSalesTax(_orderCharge.TotalCharges, taxPercent));
                _orderCharge.PlanTitle = null;
                return _orderCharge;
            }
            return null;
        }
Пример #23
0
            public async Task <IEnumerable <OrderItem> > GetItemsAsync(
                Model.Order order,
                [ScopedService] ApplicationDbContext dbContext,
                CancellationToken cancellationToken)
            {
                // Get all the order item records for this order
                OrderItem[]? orderItems = await dbContext.OrderItems
                                          .Where(oi => oi.OrderId == order.Id)
                                          .Include(bi => bi.Item)
                                          .ToArrayAsync(cancellationToken);

                return(orderItems);
            }
Пример #24
0
        public void Should_catch_a_null_element_in_the_list()
        {
            var order = new Order();
            order.Items = new List<OrderItem>();
            order.Items.Add(null);

            List<Violation> violations = _validator.Validate(order).ToList();

            Assert.AreEqual(1, violations.Count);
            Assert.AreEqual("cannot be null", violations[0].Message);
            Assert.AreEqual("Order.Items[0]", violations[0].Key);
            Assert.AreEqual("Order.Items[0] cannot be null", violations[0].ToString());
        }
Пример #25
0
        public OrderChargeModel Calculate(Order order)
        {
            var orderItems = (from c in _orderItem where c.OrderId == order.OrderId select c).ToList();
            var cookerId = orderItems.First().CookerId;
            var taxPercent = (from c in _cookers where c.CookerId == cookerId select c.TaxPercent).FirstOrDefault() ?? 1;
            var paymentMethodValue = (from c in _fakePaymentMethods where c.PaymentMethodId == order.PaymentMethodId select c.PaymentMethodValue).FirstOrDefault();
            var orderTypeValue = (from c in _fakeOrderTypes where c.OrderTypeId == order.OrderTypeId select c.OrderTypeValue).FirstOrDefault();
            var planTitle = (from c in _fakePlans where c.PlanId == order.PlanId select c.Description).FirstOrDefault();

            #region PickUpOrderCharge

            if (order.OrderTypeId == (int)OrderType.Values.PickUp)
            {
               _orderCharge = PickUpCharge(order, taxPercent);
            }

            #endregion

            #region DeliveryOrderCharge

            var cookerDelieryZonesId = (from c in _cookerDeliveryZones where c.CookerId == cookerId select c.DeliveryId).ToList();

            decimal deliveryFees = 0;
            foreach (var deliveryZoneId in cookerDelieryZonesId)
            {
                //Custom KML Function to see if the item is in the zone
                //Moq for now
                var deliveryzone = _deliveryZones.FirstOrDefault(c => c.DeliveryId == deliveryZoneId);

                //KML integration to see if deliveryaddress is Zone
                if (_deliveryAddress.AddressTypeId == (int) AddressToDeliveryZone.Values.AddressInZone)
                {
                    if (deliveryzone != null)
                    {
                        deliveryFees = deliveryzone.DeliveryFees;
                    }
                }
            }

            _orderCharge = DeliveryCharge(order, deliveryFees, taxPercent);

            #endregion

            _orderCharge.CookerId = cookerId;
            _orderCharge.PaymentMethodValue = paymentMethodValue;
            _orderCharge.OrderTypeValue = orderTypeValue;
            _orderCharge.SalesTaxes = CalculateSalesTax(_orderCharge.TotalCharges, taxPercent);
            _orderCharge.PlanTitle = planTitle;
            return _orderCharge;
        }
Пример #26
0
 //Delivery
 //Client 2
 // Cooker 1
 //  Order 2
 //Dish 4 ( 10.00)
 // OrderItemDishOptionId 3  (0.53)
 private Order FirstOrder()
 {
     var secondOrder = new Order
     {
         OrderId = 2,
         ClientId = 2,
         OrderDate = DateTime.Today.Date,
         DeliveryDate = DateTime.Today.Date,
         OrderTypeId = (int)Util.OrderType.Values.Delivery,
         PaymentMethodId = (int)PaymentMethodType.Values.CardOnLine,
         PromotionId = null,
         CouponId = null,
         PlanId = null,
         SubTotal = (decimal)10.53
     };
     secondOrder.OrderItems.Add(new FakeOrderItems().GetClient2FirstOrderFirstOrderItem());
     return secondOrder;
 }
Пример #27
0
 //Delivery
 // Client 3
 // Cooker 3
 // Order 3
 // Dish 32 (5.99)
 private Order FirstOrder()
 {
     var firstOrder = new Order
     {
         OrderId = 3,
         ClientId = 3,
         OrderDate = DateTime.Today.Date,
         DeliveryDate = null,
         OrderTypeId = (int)Util.OrderType.Values.Delivery,
         PaymentMethodId = (int)Util.PaymentMethodType.Values.Cash,
         PromotionId = null,
         CouponId = null,
         PlanId = null,
         SubTotal = (decimal)5.99
     };
     firstOrder.OrderItems.Add(new FakeOrderItems().GetClient3FirstOrderFirstOrderItem());
     return firstOrder;
 }
 //Plan
 //PlanId = 1,
 //ExternalId = "1",
 //Description = "3 Meals per week",
 //Title="Mike Weekly Plan"
 // Cooker Subscription
 // CookerSubscriptionId = 1,
 //CookerId = 1,
 //PlanId = 1,
 // ServingPriceId = 1
 //SubscriptionServingPrice
 // ServingPrice
 // {
 //     ServicePriceId = 1,
 //     ServingMeasurementId = 1,
 //     PLanId = 1,
 //     Price = (decimal)19.99,
 //     Quantity = 1
 // }
 public Order FirstOrder()
 {
     var firstOrder = new Order
     {
         OrderId = 10,
         ClientId = 1,
         OrderDate = DateTime.Today.Date,
         DeliveryDate = null,
         OrderTypeId = (int)Util.OrderType.Values.PickUp,
         PaymentMethodId = (int)PaymentMethodType.Values.CardOnLine,
         CouponId = null,
         PromotionId = null,
         PlanId = 1,
         CurrencyId = (int)CurrencyType.Values.Usd,
         SubTotal = (decimal)37.14
     };
     firstOrder.OrderItems.Add(new FakeOrderItems().GetClient1FirstOrderFirstOrderItem());
     firstOrder.OrderItems.Add(new FakeOrderItems().GetClient1FirstOrderSecondOrderItem());
     return firstOrder;
 }
Пример #29
0
		public void FirstTestName()
		{
			Order order = new Order
				{
					OrderLines = new List<OrderLine>
						{
							new OrderLine {ProductCode = 12345},
							new OrderLine {ProductCode = 67890},
						},
				};


			List<Order> orders = new List<Order>
				{
					order
				};

			IQueryable<IGrouping<int, OrderLine>> qx = from o in orders.AsQueryable()
			         from ol in o.OrderLines
			         group ol by ol.ProductCode
			         into lines
			         	let l1 = lines.Count(x => x.ProductCode == 12345)
			         	let l2 = lines.Count(x => x.ProductCode == 67890)
			         	where l1 > 0 && l2 > 0
			         	select lines;

			Trace.WriteLine(qx.Expression);

			var query = orders
				.Select(o => new
					{
						o,
						l1c = o.OrderLines
				             	.Where(x => x.ProductCode == 12345)
				             	.Count(),
						l2c = o.OrderLines.Where(x => x.ProductCode == 12345).Count()
					})
				.Where(@t => @t.l1c > 0)
				.Where(@t => @t.l2c > 0)
				.Select(@t => @t.o);
		}
Пример #30
0
        //---------------------------------------------------------------------
        /// <summary>
        /// Write order.
        /// </summary>
        /// <param name="order"></param>
        public void WriteOrder(Order order,string filePath)
        {
            XNamespace xsi = XmlSchema.InstanceNamespace;
            var rootElement = new XElement("order", new XAttribute(XNamespace.Xmlns + "xsi", xsi));
            rootElement.Add(new XElement("orderDate",order.DateTime));
            rootElement.Add(new XElement("SerialNumber",order.SerialNumber));
            var productGroup = new XElement("productCroup");

            foreach (var pg in order.ProductGroups)
            {
                productGroup.Add(new XElement("productGroupName", pg.ProductGroupName));

                foreach (var p in pg.Products)
                {
                    var product = new XElement("product");
                    product.Add(new XAttribute("id", p.Id));
                    product.Add(new XElement("productName", p.Name));
                    product.Add(new XElement("productDescription", p.Description));
                    var versionElement = new XElement("version");
                    foreach (var version in p.Versions)
                    {
                        versionElement.Add(new XElement("versionNumber", version.VersionNumber));
                        var featureElements = new XElement("feature");

                        foreach (var feature in version.Features)
                        {

                            featureElements.Add(new XElement("featureName", feature.Name));
                            featureElements.Add(new XElement("featureDescription"), feature.Description);
                        }
                      versionElement.Add(featureElements);
                    }
                    product.Add(versionElement);
                    productGroup.Add(product);
                }
                rootElement.Add(productGroup);
            }
            rootElement.Save(filePath);
        }
Пример #31
0
    private void Order()
    {
        IUserBLL userBLL = (IUserBLL)SpringContext.Context.CreateInstance("UserBLL");

        Model.Order order = new Model.Order();
        order.ID         = Guid.NewGuid();
        order.CreateTime = DateTime.Now;
        order.Status     = 0;
        order.CustomID   = userBLL.UserID;

        order.OrderProducts = shopCarBLL.GetList();
        for (int i = 0; i < order.OrderProducts.Count; i++)
        {
            order.OrderProducts[i].OrderID = order.ID;
        }

        IOrderBLL orderBll = (IOrderBLL)SpringContext.Context.CreateInstance("OrderBLL");

        orderBll.Insert(order);

        Response.Write("{success:true}");
        Response.End();
    }
Пример #32
0
		public void A_complete_order()
		{
			CurrentOrder = new Order
				{
					Customer = new Customer
						{
							Preferred = false,
							Active = true,
							LastActivity = SystemUtil.Now - 5.Days(),
						},
					Source = "Online",
					OrderLines = new List<OrderLine>
						{
							new OrderLine
								{
									ProductCode = 12345
								},
							new OrderLine
								{
									ProductCode = 67890
								},
						},
				};
		}
Пример #33
0
        public IActionResult Payment(string shipName, string mobile, string address, string email)
        {
            var order = new Model.Order();

            order.CreateDate  = DateTime.Now;
            order.ShipAddress = address;
            order.ShipEmail   = email;
            order.ShipName    = shipName;
            order.ShipMobile  = mobile;

            try
            {
                var     id        = new OrderDao().Insert(order);
                var     cart      = SessionHelper.SessionHelper.GetTObjectFromJson <List <CartItem> >(HttpContext.Session, CartSession);
                decimal total     = 0;
                var     detailDao = new OrderDetailDao();
                foreach (var item in cart)
                {
                    var orderDetail = new OrderDetail();
                    orderDetail.ProductId = item.Product.Id;
                    orderDetail.OrderId   = id;
                    orderDetail.Price     = item.Product.Price;
                    orderDetail.Quantity  = item.Quantity;
                    detailDao.Insert(orderDetail);

                    total += (item.Product.Price.GetValueOrDefault(0) * item.Quantity);
                }

                //var message = new MimeMessage();
                MailMessage message = new MailMessage(new MailAddress("*****@*****.**", "Hao Lyhien"), new MailAddress(email));
                //message.From.Add(new MailboxAddress("Hao Lyhien","*****@*****.**"));

                //message.To.Add(new MailboxAddress("Đơn hàng mới từ Web vi tính", "*****@*****.**"));

                message.Subject = "Đơn hàng mới từ webvitinh";

                string content = System.IO.File.ReadAllText("wwwroot/Client/template/neworder.html");
                content = content.Replace("{{OrderId}}", id.ToString());
                content = content.Replace("{{CustomerName}}", shipName);
                content = content.Replace("{{Phone}}", mobile);
                content = content.Replace("{{Email}}", email);
                content = content.Replace("{{Address}}", address);
                content = content.Replace("{{Total}}", total.ToString("N0"));

                message.Body = content;

                var credentials = new NetworkCredential("*****@*****.**", "ronaldo142");
                using (var client = new SmtpClient())
                {
                    client.Port                  = 587;
                    client.Host                  = "smtp.gmail.com";
                    client.DeliveryMethod        = SmtpDeliveryMethod.Network;
                    client.UseDefaultCredentials = false;
                    client.EnableSsl             = true;
                    client.Credentials           = credentials;
                    client.Send(message);
                }
            }
            catch (Exception ex)
            {
                //ghi log
                return(Redirect("/loi-thanh-toan"));
            }
            return(Redirect("/hoan-thanh"));
        }
 public void DeleteOrder(Order order)
 {
     deleter.Delete(order);
 }
 public void UpdateOrder(Order order)
 {
     saver.Save(order);
 }