Example #1
0
        public async Task <Result <int> > CreateAsync(CreateOrderItemRequest request)
        {
            if (request is null)
            {
                throw new ArgumentNullException(nameof(request));
            }

            var provisioningType   = ProvisioningType.FromName(request.ProvisioningTypeName);
            var cataloguePriceType = CataloguePriceType.FromName(request.CataloguePriceTypeName);
            var cataloguePriceUnit = CataloguePriceUnit.Create(request.CataloguePriceUnitTierName, request.CataloguePriceUnitDescription);

            var priceTimeUnit    = TimeUnit.FromName(request.PriceTimeUnitName);
            var estimationPeriod = TimeUnit.FromName(request.EstimationPeriodName);

            var orderItem = new OrderItem(
                request.OdsCode,
                request.CatalogueItemId,
                request.CatalogueItemType,
                request.CatalogueItemName,
                provisioningType,
                cataloguePriceType,
                cataloguePriceUnit,
                priceTimeUnit,
                request.CurrencyCode,
                request.Quantity,
                estimationPeriod,
                request.DeliveryDate,
                request.Price);

            Order order = request.Order;

            order.AddOrderItem(orderItem,
                               _identityService.GetUserIdentity(),
                               _identityService.GetUserName());

            await _orderRepository.UpdateOrderAsync(order);

            return(Result.Success(orderItem.OrderItemId));
        }
Example #2
0
        public async Task <Result> UpdateAsync(UpdateOrderItemRequest request)
        {
            if (request is null)
            {
                throw new ArgumentNullException(nameof(request));
            }

            var estimationPeriod = TimeUnit.FromName(request.EstimationPeriodName);

            Order order = request.Order;

            order.UpdateOrderItem(
                request.OrderItemId,
                request.DeliveryDate,
                request.Quantity,
                estimationPeriod,
                request.Price,
                _identityService.GetUserIdentity(),
                _identityService.GetUserName());

            await _orderRepository.UpdateOrderAsync(order);

            return(Result.Success());
        }
Example #3
0
        public void FromName_UnknownTimeUnitId_ReturnsNull(string name)
        {
            var actual = TimeUnit.FromName(name);

            actual.Should().BeNull();
        }
Example #4
0
        public void FromName_TimeUnitId_ReturnsExpectedType(string timeUnitName)
        {
            var actual = TimeUnit.FromName(timeUnitName);

            actual.Should().Be(TimeUnit.PerMonth);
        }