Exemplo n.º 1
0
		public void Encode(General.Encoding.BinaryOutput stream) {
			stream.Write(position);
			stream.Write(model.Name);
			stream.Write(entityIndex);

			EntityIO writer = new EntityIO(stream, null, true);
			writer.Write(worldEntity);
		}
Exemplo n.º 2
0
        public void Encode(General.Encoding.BinaryOutput stream)
        {
            stream.Write(position);
            stream.Write(model.Name);
            stream.Write(entityIndex);

            EntityIO writer = new EntityIO(stream, null, true);

            writer.Write(worldEntity);
        }
Exemplo n.º 3
0
        public IEncodable Decode(General.Encoding.BinaryInput stream)
        {
            position    = stream.ReadVector2();
            modelName   = stream.ReadString();
            entityIndex = stream.ReadInt32();

            if (!string.IsNullOrEmpty(modelName))
            {
                World world = EditorEngine.Instance.World;
                model = EditorEngine.Instance.GetModelByName(modelName);
            }

            EntityIO io = new EntityIO(stream, EditorEngine.Instance.CurrentMap.Factory, true);

            this.worldEntity = io.Read();

            return(this);
        }
Exemplo n.º 4
0
		public IEncodable Decode(General.Encoding.BinaryInput stream) {
			position = stream.ReadVector2();
			modelName = stream.ReadString();
			entityIndex = stream.ReadInt32();
			
			if (!string.IsNullOrEmpty(modelName)) {
				World world = EditorEngine.Instance.World;
				model = EditorEngine.Instance.GetModelByName(modelName);
			}

			EntityIO io = new EntityIO(stream, EditorEngine.Instance.CurrentMap.Factory, true);
			this.worldEntity = io.Read();

			return this;
		}
Exemplo n.º 5
0
        static void Main(string[] args)
        {
            //Testing the OrderService
            EntityIO <Order> orderRepository = new EntityIO <Order>();

            Console.WriteLine(orderRepository.Count());

            Order ord = new Entities.Order();

            ord.OrderDate    = DateTime.Today;
            ord.ShipmentDate = DateTime.Today.AddDays(3);
            ord.CustomerId   = 3;
            ord.TotalPrice   = 0M;

            orderRepository.Insert(ord);

            var order = (from o in orderRepository.Query()
                         where o.OrderId == 5
                         select o).SingleOrDefault();

            Console.WriteLine(String.Format("Order with the id {0} has a total price of {1}, the order was made on {2} and the shipment is estimated on {3}",
                                            order.OrderId,
                                            order.TotalPrice,
                                            order.OrderDate,
                                            order.ShipmentDate));

            //Add the 3 most expensive products to the order (useful, if if there was a 'menu of the day')
            EntityIO <Product> productRepository = new EntityIO <Product>();
            var products = (from p in productRepository.Query()
                            orderby p.Price descending
                            select p).Take(3).ToList();


            EntityIO <OrderProduct> orderProductRepository = new EntityIO <OrderProduct>();

            foreach (var product in products)
            {
                OrderProduct orderProduct = new OrderProduct();

                orderProduct.Quantity  = products.GroupBy(p => product).ToList().Count();
                orderProduct.OrderId   = 5;
                orderProduct.ProductId = product.ProductId;

                orderProductRepository.Insert(orderProduct);
            }


            var orderedProducts = (from op in orderProductRepository.Query()
                                   where op.OrderId == 5
                                   select new { op.ProductId, op.Quantity }).ToList();

            var prroducts = (from p in productRepository.Query()
                             select new { p.ProductId, p.Price }).ToList();

            decimal price = 0;

            foreach (var product in orderedProducts)
            {
                var prod = prroducts.SingleOrDefault(x => x.ProductId == product.ProductId);

                price += prod.Price * product.Quantity;
            }

            Order ordern = (from o in orderRepository.Query()
                            where o.OrderId == 5
                            select o).SingleOrDefault();

            ordern.TotalPrice = price;

            orderRepository.Update(ordern);

            Console.WriteLine(String.Format("Order with the id {0} has a total price of {1}, the order was made on {2} and the shipment is estimated on {3}",
                                            ordern.OrderId,
                                            ordern.TotalPrice,
                                            ordern.OrderDate,
                                            ordern.ShipmentDate));


            Console.ReadLine();

            /*  //Creates order
             * DateTime shipmentDate = DateTime.Today;
             * shipmentDate.AddDays(3);
             *
             * orderClient.CreateOrder(DateTime.Today, shipmentDate, 0, 2);
             *
             * //Add the 3 most expensive products to the order (useful, if if there was a 'menu of the day')
             * var products = productClient.GetTopMostExpensiveProducts(3);
             * //Manual conversion from ProductService.Product to OrderService.Product
             * var orderProducts = new List<OrderService.Product>();
             * foreach(var prod in products)
             * {
             *    var pr = new OrderService.Product();
             *
             *    pr.Name = prod.Name;
             *    pr.Description = prod.Description;
             *    pr.ProductId = prod.ProductId;
             *    pr.Kcal = prod.Kcal;
             *    pr.Price = prod.Price;
             *
             *    orderProducts.Add(pr);
             * }
             * orderClient.AddProductsToOrder(5, orderProducts);
             *
             * Console.WriteLine("The order we have jut placed:");
             * Console.WriteLine(orderClient.DisplayOrder(5));
             */
        }
Exemplo n.º 6
0
 public ProductService()
 {
     this.productRepository      = new EntityIO <Product>();
     this.orderProductRepository = new EntityIO <OrderProduct>();
 }
Exemplo n.º 7
0
 public CustomerService()
 {
     this.customerRepository = new EntityIO <Customer>();
 }