public void TestCalculateOrderDiscountWithMethod1()
        {
            int orderId = 10693;

            OrderDetailMapper orderDetailMapper = new OrderDetailMapper();

            IList <OrderDetail> orderDetails = orderDetailMapper.FindOrderDetailByCriterion(orderId);

            foreach (OrderDetail orderDetail in orderDetails)
            {
                orderDetail.CalculateOrderDiscount1();
            }

            Assert.AreEqual(4, orderDetails.Count);

            Assert.AreEqual(6, orderDetails[0].Quantity);
            Assert.AreEqual(0.00f, orderDetails[0].Discount);

            Assert.AreEqual(60, orderDetails[1].Quantity);
            Assert.AreEqual(0.20f, orderDetails[1].Discount);

            Assert.AreEqual(30, orderDetails[2].Quantity);
            Assert.AreEqual(0.15f, orderDetails[2].Discount);

            Assert.AreEqual(15, orderDetails[3].Quantity);
            Assert.AreEqual(0.15f, orderDetails[3].Discount);
        }
        public void TestFindOrderDetailByCriterion()
        {
            int orderId = 10693;

            OrderDetailMapper orderDetailMapper = new OrderDetailMapper();

            IList <OrderDetail> orderDetails = orderDetailMapper.FindOrderDetailByCriterion(orderId);

            Assert.AreEqual(4, orderDetails.Count);

            Assert.AreEqual(orderId, orderDetails[0].OrderID);
            Assert.AreEqual(9, orderDetails[0].ProductID);
            Assert.AreEqual(6, orderDetails[0].Quantity);
            Assert.AreEqual(0f, orderDetails[0].Discount);

            Assert.AreEqual(orderId, orderDetails[1].OrderID);
            Assert.AreEqual(54, orderDetails[1].ProductID);
            Assert.AreEqual(60, orderDetails[1].Quantity);
            Assert.AreEqual(0.15f, orderDetails[1].Discount);

            Assert.AreEqual(orderId, orderDetails[2].OrderID);
            Assert.AreEqual(69, orderDetails[2].ProductID);
            Assert.AreEqual(30, orderDetails[2].Quantity);
            Assert.AreEqual(0.15f, orderDetails[2].Discount);

            Assert.AreEqual(orderId, orderDetails[3].OrderID);
            Assert.AreEqual(73, orderDetails[3].ProductID);
            Assert.AreEqual(15, orderDetails[3].Quantity);
            Assert.AreEqual(0.15f, orderDetails[3].Discount);
        }
        public List <OrderDetailsDTO> GetOrderDetails()
        {
            var returnList = new List <OrderDetailsDTO>();

            foreach (var item in pssc.GetPizzaOrderDetails())
            {
                returnList.Add(OrderDetailMapper.MapToDTO(item));
            }

            return(returnList);
        }
        public void TestFindOrderDetailById()
        {
            int orderId   = 10693;
            int productId = 9;

            OrderDetailMapper orderDetailMapper = new OrderDetailMapper();

            OrderDetail orderDetail = orderDetailMapper.FindOrderDetailById(orderId, productId);

            Assert.AreEqual(10693, orderDetail.OrderID);
            Assert.AreEqual(9, orderDetail.ProductID);
            Assert.AreEqual(6, orderDetail.Quantity);
            Assert.AreEqual(0f, orderDetail.Discount);
            Assert.AreEqual("10693:9", orderDetail.DomainId);
        }
        public void TestReFindOrderDetailByCriterionUseIdentityMap()
        {
            int orderId = 10693;

            OrderDetailMapper orderDetailMapper = new OrderDetailMapper();

            IList <OrderDetail> orderDetails = orderDetailMapper.FindOrderDetailByCriterion(orderId);

            IList <OrderDetail> orderDetailsFromIdentityMap = orderDetailMapper.FindOrderDetailByCriterion(orderId);

            for (int i = 0; i < orderDetails.Count; i++)
            {
                Assert.AreEqual(orderDetails[i], orderDetailsFromIdentityMap[i]);
            }


            int productId = 9;

            OrderDetail orderDetailSingle = orderDetailMapper.FindOrderDetailById(orderId, productId);

            Assert.AreEqual(orderDetails[0], orderDetailSingle);
        }
        public override void Execute(object parameter)
        {
            List <OrderDetail>      orderDetails      = DB.OrderDetailRepository.GetOrderDetails(orderViewModel.CurrentOrder.Id);
            List <OrderDetailModel> orderDetailModels = new List <OrderDetailModel>();
            OrderDetailMapper       orderDetailMapper = new OrderDetailMapper();

            for (int i = 0; i < orderDetails.Count; i++)
            {
                OrderDetail orderDetail = orderDetails[i];

                OrderDetailModel orderDetailModel = orderDetailMapper.Map(orderDetail);
                orderDetailModel.No = i + 1;

                orderDetailModels.Add(orderDetailModel);
            }
            orderViewModel.OrderDetails = orderDetailModels;
            OrderInformation orderInformation = new OrderInformation();

            orderInformation.DataContext           = orderViewModel;
            orderInformation.WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen;
            orderInformation.ShowDialog();
        }
 public bool InsertOrderDetail(OrderDetailsDTO item)
 {
     return(pssc.InsertPizzaOrderDetail(OrderDetailMapper.MapToDAO(item)));
 }
 public bool DeleteOrderDetail(OrderDetailsDTO item)
 {
     return(pssc.DeletePizzaOrderDetail(OrderDetailMapper.MapToDAO(item)));
 }
 public bool ChangeOrderDetail(OrderDetailsDTO item)
 {
     return(pssc.ChangePizzaOrderDetail(OrderDetailMapper.MapToDAO(item)));
 }
 public OrderDetailsDTO GetOrderDetail(int id)
 {
     return(OrderDetailMapper.MapToDTO(pssc.GetPizzaOrderDetail(id)));
 }