Ejemplo n.º 1
0
        public void Process(CustomersOrder order)
        {
            var oldOrder = _repository.GetOldOrderId(order.Code);

            if (oldOrder == 0)
            {
                _repository.SaveOrder(order);
            }
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            var cust      = new Customer();
            var custOrder = new CustomersOrder();

            #region PopulatingCustomer
            //Populating OrderDto
            var dto1 = new OrderDto {
                Code = 1, CustomerCode = 1, OrderDate = DateTime.Now.Date, OrderStatus = "OK"
            };
            //Populating Customer
            var customerList      = cust.Customers = new List <Customer>();
            var customerOrderList = custOrder.CustomersOrders = new List <CustomersOrder>();

            var customer1 = new Customer
            {
                Code = 1,
                ID   = 1, Order = dto1
            };
            var customer2 = new Customer
            {
                Code = 2,
                ID   = 2,
            };

            customerList.Add(customer1);
            customerList.Add(customer2);
            #endregion

            #region PopulatingCustomerOrder

            var customersOrder1 = new CustomersOrder {
                Code = 1, CustomerID = 1, ID = 1, Order = dto1, OrderDate = dto1.OrderDate, OrderStatus = dto1.OrderStatus
            };
            customerOrderList.Add(customersOrder1);
            #endregion

            #region InvokingMethods
            //IRepository
            IRepository IRepo = new Repository(cust, custOrder);

            //OrderProcessor
            var orderProcesor = new OrderProcess(IRepo);

            //OrderBuilder
            var dto2 = new OrderDto {
                Code = 2, CustomerCode = 2, OrderDate = DateTime.Now.Date, OrderStatus = "OK"
            };
            var oBuilder     = new OrderBuilder(IRepo);
            var newCustOrder = oBuilder.OrderBuild(dto2);
            customerOrderList.Add(newCustOrder);
            #endregion
            Console.Read();
        }
Ejemplo n.º 3
0
 public Repository(Customer cust, CustomersOrder custOrder)
 {
     _cust      = cust;
     _custOrder = custOrder;
 }
Ejemplo n.º 4
0
 public void SaveOrder(CustomersOrder order)
 {
     _custOrder.CustomersOrders.Add(order);
 }