Example #1
0
        public Guid CreateOrder(OrderRequest request)
        {
            var pc     = _pcRepo.Get(request.PcId);
            var client = _clientRepo.Get(request.ClientId);

            var order = _orderFactory.CreateOrder(client, pc, request.Quantity, request.DestinationCountry);

            order.GetDiscount();
            _taxService.CalculateTaxes(order);

            if (!_orderValidationService.ValidateOrder(order))
            {
                throw new ArgumentException();
            }

            _deliveryService.EstimateDelivery(order);
            _clientRepo.SubtractMoney(client.Id, order.Price);
            _notifier.Notify(client, "An order has been made");

            return(_ordersRepo.Save(order).Id);
        }