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 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()); }
public void FromName_UnknownTimeUnitId_ReturnsNull(string name) { var actual = TimeUnit.FromName(name); actual.Should().BeNull(); }
public void FromName_TimeUnitId_ReturnsExpectedType(string timeUnitName) { var actual = TimeUnit.FromName(timeUnitName); actual.Should().Be(TimeUnit.PerMonth); }