I've started getting these errors:
public override async Task<ProductDto> CreateAsync([FromForm] CreateProductDto input)
{
CheckCreatePermission();
if (_abpSession.UserId == null)
{
throw new UserFriendlyException("M0026");
}
input.UserId = _abpSession.UserId.Value;
var product = await base.CreateAsync(input);
await CurrentUnitOfWork.SaveChangesAsync();
Task.Run(() => UploadProductMediaToAzure(product.Id, input.Medias));
return ObjectMapper.Map<ProductDto>(product);
}
public async Task UploadProductMediaToAzure(long productId, List<IFormFile> files)
{
try
{
if (files != null)
{
using (var uow = _unitOfWorkManager.Begin(TransactionScopeOption.RequiresNew))
{
byte displayOrder = 1;
foreach (var item in files)
{
var fileName = item.FileName;
var fileMimeType = item.ContentType;
Product.ProductMedia productMedia = new()
{
ProductId = productId,
Name = item.FileName,
Type = Constant.FileType.Video,
DisplayOrder = displayOrder
};
await _productMediaRepository.InsertAsync(productMedia);
displayOrder++;
}
uow.Complete();
}
}
}
catch (Exception e)
{
throw e;
}
}
And I get exception System.ArgumentNullException: 'Value cannot be null. (Parameter 'unitOfWork')' occurred in line: await _productMediaRepository.InsertAsync(productMedia);
Please help me figure this out.