if (fileCSV == null && fileCSV.ContentLength == 0)
{
importModel.Error = "Error1";
return importModel;
}
else
{
List<ImportModel> mappings = _importService.ImportCSVToList<ImportModel>(fileCSV);
if (mappings.Count > 0)
{
IEnumerable<ImportModel> duplicates = mappings.GroupBy(x => x.ProductSku).SelectMany(g => g.Skip(1)).ToList();
if (duplicates.Any())
{
importModel.Error = "Error2";
return importModel;
}
else
{
var products = _productService.GetProducts(productSkuList).ToList();
if (!importModel.InvalidSkuList.Any())
{
bool isImported = _productService.Import(mappings);
if (!isImported)
{
importModel.Error = "Error3";
}
}
else
{
return importModel;
}
}
}
else
{
importModel.Error = "Error4";
return importModel;
}
}
Became Hot Network Question