private void PrepareConvertedTableForDatabaseUpdate(FuelManagementPrices.SupplierFuelsPricesDataTable convertedTable) { //Update the records with the appropriate admin/supplier foreach (FuelManagementPrices.SupplierFuelsPricesRow row in convertedTable.Rows) { row.AdminClientId = _AdminClientId; row.SupplierId = _SupplierId; } }
private FuelManagementPrices.SupplierFuelsPricesDataTable ConvertUploadedDataTable() { FuelManagementPrices.SupplierFuelsPricesDataTable result = null; foreach (DataSheet supportedDataSheet in _SuppoortedSheetCollection) { result = AttemptToConvertFormat(supportedDataSheet); if (result != null && result.Rows.Count > 0) { return(result); } } return(null); }
private FuelManagementPrices.SupplierFuelsPricesDataTable AttemptToConvertFormat(DataSheet supportedDataSheet) { FuelManagementPrices.SupplierFuelsPricesDataTable result = new FuelManagementPrices.SupplierFuelsPricesDataTable(); try { if (!supportedDataSheet.PopulateRowsFromData(result, _UploadedSheetTable)) { return(null); } } catch (Exception exception) { throw new Exception(exception.ToString()); } return(result); }
public bool Process(string fileName, Users user, Suppliers supplier) { _FileName = fileName; _SupplierId = supplier.Id; _AdminClientId = user.Client.Id; _SuppoortedSheetCollection = TemplateLoader.GetSupplierDataSheetCollection(user.Client.Name, supplier.SupplierName); LoadFileIntoDataTable(); FuelManagementPrices.SupplierFuelsPricesDataTable convertedTable = ConvertUploadedDataTable(); if (convertedTable == null) { return(false); } PrepareConvertedTableForDatabaseUpdate(convertedTable); UploadDatabaseRecords(convertedTable); if (convertedTable.Rows.Count == 0) { return(false); } return(true); }