Compare commits
No commits in common. "5439fcfb75920974055247801adae3ceddfcb9b3" and "be127319e27d630ce14c793fc50bccd576e5fb7b" have entirely different histories.
5439fcfb75
...
be127319e2
30
RhSolutions.SkuParser.Api/Models/ProductQuantity.cs
Normal file
30
RhSolutions.SkuParser.Api/Models/ProductQuantity.cs
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
using CsvHelper.Configuration.Attributes;
|
||||||
|
|
||||||
|
namespace RhSolutions.SkuParser.Models;
|
||||||
|
|
||||||
|
public class ProductQuantity
|
||||||
|
{
|
||||||
|
[Index(0)]
|
||||||
|
public required Product Product { get; set; }
|
||||||
|
[Index(1)]
|
||||||
|
public required double Quantity { get; set; }
|
||||||
|
|
||||||
|
public override bool Equals(object? obj)
|
||||||
|
{
|
||||||
|
if (obj == null || GetType() != obj.GetType())
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
ProductQuantity other = (ProductQuantity)obj;
|
||||||
|
return Product == other.Product &&
|
||||||
|
Quantity == other.Quantity;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override int GetHashCode()
|
||||||
|
{
|
||||||
|
HashCode hash = new();
|
||||||
|
hash.Add(Product);
|
||||||
|
hash.Add(Quantity);
|
||||||
|
return hash.ToHashCode();
|
||||||
|
}
|
||||||
|
}
|
@ -1,11 +0,0 @@
|
|||||||
using CsvHelper.Configuration.Attributes;
|
|
||||||
|
|
||||||
namespace RhSolutions.SkuParser.Models;
|
|
||||||
|
|
||||||
public record SkuQuantity
|
|
||||||
{
|
|
||||||
[Index(0)]
|
|
||||||
public required string Sku { get; set; }
|
|
||||||
[Index(1)]
|
|
||||||
public required double Quantity { get; set; }
|
|
||||||
}
|
|
@ -8,11 +8,13 @@ namespace RhSolutions.SkuParser.Api.Services;
|
|||||||
public class BsExcelParser : ISkuParser
|
public class BsExcelParser : ISkuParser
|
||||||
{
|
{
|
||||||
private IConfiguration configuration;
|
private IConfiguration configuration;
|
||||||
|
// private Dictionary<Product, double> result;
|
||||||
private const int rowsLookupCount = 20;
|
private const int rowsLookupCount = 20;
|
||||||
private const decimal vat = 1.2M;
|
private const decimal vat = 1.2M;
|
||||||
public BsExcelParser(IConfiguration configuration)
|
public BsExcelParser(IConfiguration configuration)
|
||||||
{
|
{
|
||||||
this.configuration = configuration;
|
this.configuration = configuration;
|
||||||
|
// result = new();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Dictionary<Product, double> ParseProducts(IFormFile file)
|
public Dictionary<Product, double> ParseProducts(IFormFile file)
|
||||||
|
@ -20,7 +20,7 @@ public class CommonCsvParser : ISkuParser
|
|||||||
};
|
};
|
||||||
using CsvReader csvReader = new(reader, config);
|
using CsvReader csvReader = new(reader, config);
|
||||||
|
|
||||||
return csvReader.GetRecords<SkuQuantity>()
|
return csvReader.GetRecords<ProductQuantity>()
|
||||||
.ToDictionary(pq => new Product() { Sku = pq.Sku }, pq => pq.Quantity);
|
.ToDictionary(pq => new Product() { Sku = pq.Product.Sku }, pq => pq.Quantity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user