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)); }
public void FromName_UnknownCataloguePriceTypeId_ReturnsNull() { var actual = CataloguePriceType.FromName("Unknown"); actual.Should().BeNull(); }
static void Test() { CataloguePriceType.FromName(null); }
public void FromName_CataloguePriceTypeId_ReturnsExpectedType(string cataloguePriceTypeName) { var actual = CataloguePriceType.FromName(cataloguePriceTypeName); actual.Should().Be(CataloguePriceType.Tiered); }