public long Store(DhlInvoiceDTO invoice) { var entity = new DhlInvoice() { OrderNumber = invoice.OrderNumber, Status = invoice.Status, InvoiceDate = invoice.InvoiceDate, InvoiceNumber = invoice.InvoiceNumber, BillNumber = invoice.BillNumber, Dimensions = invoice.Dimensions, ChargedBase = invoice.ChargedBase, ChargedSummary = invoice.ChargedSummary, ChargedCredit = invoice.ChargedCredit, Estimated = invoice.Estimated, SourceFile = invoice.SourceFile, CreateDate = invoice.CreateDate, }; Add(entity); unitOfWork.Commit(); return(entity.Id); }
public void Update(DhlInvoiceDTO invoice) { var existEntry = Get(invoice.Id); if (existEntry != null) { existEntry.Dimensions = invoice.Dimensions; } unitOfWork.Commit(); }
public IList <DhlInvoiceDTO> GetRecordsFromFile(string filePath) { StreamReader streamReader = new StreamReader(filePath); CsvReader reader = new CsvReader(streamReader, new CsvConfiguration { HasHeaderRecord = true, Delimiter = ",", TrimFields = true, }); var filename = Path.GetFileName(filePath); var results = new List <DhlInvoiceDTO>(); while (reader.Read()) { var invoice = new DhlInvoiceDTO(); invoice.InvoiceNumber = reader.GetField <string>("INVOICE #"); invoice.InvoiceDate = reader.GetField <DateTime>("INVOICE DATE"); invoice.BillNumber = reader.GetField <string>("AIRBILL #"); invoice.Dimensions = reader.GetField <string>("DIMENSIONS"); invoice.SourceFile = filename; invoice.OrderNumber = reader.GetField <string>("SHIPPER REFERENCE"); invoice.ChargedBase = reader.GetField <decimal>("BASE CHARGE AMOUNT"); invoice.ChargedSummary = reader.GetField <decimal>("BASE CHARGE AMOUNT") + (reader.GetField <decimal?>("CHARGE 1 AMT") ?? 0) + (reader.GetField <decimal?>("CHARGE 2 AMT") ?? 0) + (reader.GetField <decimal?>("CHARGE 3 AMT") ?? 0) + (reader.GetField <decimal?>("CHARGE 4 AMT") ?? 0) + (reader.GetField <decimal?>("CHARGE 5 AMT") ?? 0) + (reader.GetField <decimal?>("CHARGE 6 AMT") ?? 0) + (reader.GetField <decimal?>("CHARGE 7 AMT") ?? 0) + (reader.GetField <decimal?>("CHARGE 8 AMT") ?? 0); invoice.ChargedCredit = (reader.GetField <decimal?>("CREDIT 1 AMT") ?? 0) + (reader.GetField <decimal?>("CREDIT 2 AMT") ?? 0) + (reader.GetField <decimal?>("CREDIT 3 AMT") ?? 0); invoice.CreateDate = _time.GetAppNowTime(); results.Add(invoice); } _log.Info("File was processed, file: " + filename + ", records: " + results.Count); return(results); }
public DhlInvoiceViewModel(DhlInvoiceDTO invoice) { Id = invoice.Id; OrderNumber = invoice.OrderNumber; Status = invoice.Status; InvoiceDate = invoice.InvoiceDate; InvoiceNumber = invoice.InvoiceNumber; Country = invoice.Country; RateCode = invoice.RateCode; Dimensions = invoice.Dimensions; BillNumber = invoice.BillNumber; Charged = invoice.ChargedSummary; Estimated = invoice.Estimated; }
public IList <DhlInvoiceDTO> GetIBCRecordsFromFile(string filePath) { StreamReader streamReader = new StreamReader(filePath); CsvReader reader = new CsvReader(streamReader, new CsvConfiguration { HasHeaderRecord = true, Delimiter = ",", TrimFields = true, }); var filename = Path.GetFileName(filePath); var results = new List <DhlInvoiceDTO>(); while (reader.Read()) { var invoice = new DhlInvoiceDTO(); invoice.InvoiceNumber = reader.GetField <string>("Invoice Number"); invoice.InvoiceDate = reader.GetField <DateTime>("Ship Date"); invoice.BillNumber = reader.GetField <string>("Package ID"); invoice.Dimensions = reader.GetField <string>("Weight"); invoice.SourceFile = filename; invoice.OrderNumber = reader.GetField <string>("Customer Reference Number"); invoice.ChargedBase = reader.GetField <decimal>("Weight Charge"); invoice.ChargedSummary = reader.GetField <decimal>("Total Charge"); invoice.CreateDate = _time.GetAppNowTime(); results.Add(invoice); } _log.Info("File was processed, file: " + filename + ", records: " + results.Count); return(results); }