Beispiel #1
0
        public decimal GetItemsCount()
        {
            var     buyer  = new BuyerInterface();
            string  answer = buyer.ItemsMassage();
            decimal result;

            decimal.TryParse(answer, out result);
            return(result);
        }
Beispiel #2
0
        public int GetProductId(ProductData productData)
        {
            var buyer  = new BuyerInterface();
            var answer = buyer.ShowProducts(productData);
            int result;

            int.TryParse(answer, out result);
            return(result);
        }
Beispiel #3
0
        public int ShowDelivery(DeliveryData deliveryData)
        {
            var byer   = new BuyerInterface();
            var answer = byer.ShowDeliveries(deliveryData);
            int result;

            int.TryParse(answer, out result);
            return(result);
        }
Beispiel #4
0
        public void CreateOrder(DeliveryData deliveryData, OrderData orderData, ProductData productData, Buyer buyer)
        {
            bool isExist = IsExist(orderData, buyer);
            var  answer  = 2;
            var  order   = new OrderUI();

            if (isExist)
            {
                answer = GetResult();
            }
            if (answer == 1)
            {
                var buyerClient = new BuyerInterface();
                buyerClient.ShowOrder(orderData, default, buyer, false);
Beispiel #5
0
        public decimal UpdateProduct(ProductData productData, int productId, decimal value, string action)
        {
            var     product = new ProductService();
            decimal result  = 0;

            if (action == "dec")
            {
                var isEnough = product.DecrementProducts(productData, value, out value, productId);
                if (!isEnough)
                {
                    BuyerInterface buyerClient = new BuyerInterface();
                    buyerClient.ShowQuantErrMassage(value);
                }
                result = value;
            }
            if (action == "inc")
            {
                result = product.IncrementProducts(productData, value, productId);
            }
            return(result);
        }
Beispiel #6
0
        public void CreateOrder(DeliveryData deliveryData, OrderData orderData, ProductData productData, Buyer buyer)
        {
            bool isContinue   = true;
            var  buyerClient  = new BuyerInterface();
            var  orderService = new OrderService();
            var  delivery     = new DeliveryUI();
            int  id           = GetId(orderData);

            while (isContinue)
            {
                orderData.Orders.Add(orderService.AddOrderItem(productData, buyer, id));
                isContinue = buyerClient.Continue();
            }
            decimal totalPrice    = delivery.GetDeliveryPrice(orderData, buyer);
            decimal deliveryPrice = delivery.GetDelivery(deliveryData);

            delivery.SetDeliveryPrice(orderData, buyer, deliveryPrice);
            totalPrice += deliveryPrice;
            buyerClient.ShowOrder(orderData, totalPrice, buyer, true);
            var logger = new Logger();

            logger.SaveIntoFile("The total order`s price was calculated");
        }