public static Domain.AggregatesModel.ProductAggregate.Product ToProduct(this CsvFileModel record) { var product = new Domain.AggregatesModel.ProductAggregate.Product(record.ToProductKey(), record.Description, record.Price, record.DiscountPrice, record.Q1); product.SetCreatedDate(); product.SetProductVariant(record.ToProductVariant()); return(product); }
private async Task CreateOrUpdateProduct(CsvFileModel record) { var product = await _productRepository.GetByKeyAsync(record.ToProductKey()); if (product == null) { _productRepository.Add(record.ToProduct()); } else { product.UpdateProduct(record); product.SetProductVariant(CreateOrUpdateProductVariant(product, record)); _productRepository.Update(product); } await _productRepository.UnitOfWork.SaveEntitiesAsync(); }