mirror of
https://github.com/hargata/lubelog.git
synced 2025-12-10 18:36:38 -06:00
Merge pull request #558 from hargata/Hargata/545
enable extra fields to be imported via CSV
This commit is contained in:
commit
6cf733b9c6
@ -439,7 +439,8 @@ namespace CarCareTracker.Controllers
|
|||||||
Mileage = decimal.ToInt32(decimal.Parse(importModel.Odometer, NumberStyles.Any)),
|
Mileage = decimal.ToInt32(decimal.Parse(importModel.Odometer, NumberStyles.Any)),
|
||||||
Gallons = decimal.Parse(importModel.FuelConsumed, NumberStyles.Any),
|
Gallons = decimal.Parse(importModel.FuelConsumed, NumberStyles.Any),
|
||||||
Notes = string.IsNullOrWhiteSpace(importModel.Notes) ? "" : importModel.Notes,
|
Notes = string.IsNullOrWhiteSpace(importModel.Notes) ? "" : importModel.Notes,
|
||||||
Tags = string.IsNullOrWhiteSpace(importModel.Tags) ? [] : importModel.Tags.Split(" ").ToList()
|
Tags = string.IsNullOrWhiteSpace(importModel.Tags) ? [] : importModel.Tags.Split(" ").ToList(),
|
||||||
|
ExtraFields = importModel.ExtraFields.Any() ? importModel.ExtraFields.Select(x => new ExtraField { Name = x.Key, Value = x.Value }).ToList() : new List<ExtraField>()
|
||||||
};
|
};
|
||||||
if (string.IsNullOrWhiteSpace(importModel.Cost) && !string.IsNullOrWhiteSpace(importModel.Price))
|
if (string.IsNullOrWhiteSpace(importModel.Cost) && !string.IsNullOrWhiteSpace(importModel.Price))
|
||||||
{
|
{
|
||||||
@ -495,7 +496,8 @@ namespace CarCareTracker.Controllers
|
|||||||
Description = string.IsNullOrWhiteSpace(importModel.Description) ? $"Service Record on {importModel.Date}" : importModel.Description,
|
Description = string.IsNullOrWhiteSpace(importModel.Description) ? $"Service Record on {importModel.Date}" : importModel.Description,
|
||||||
Notes = string.IsNullOrWhiteSpace(importModel.Notes) ? "" : importModel.Notes,
|
Notes = string.IsNullOrWhiteSpace(importModel.Notes) ? "" : importModel.Notes,
|
||||||
Cost = decimal.Parse(importModel.Cost, NumberStyles.Any),
|
Cost = decimal.Parse(importModel.Cost, NumberStyles.Any),
|
||||||
Tags = string.IsNullOrWhiteSpace(importModel.Tags) ? [] : importModel.Tags.Split(" ").ToList()
|
Tags = string.IsNullOrWhiteSpace(importModel.Tags) ? [] : importModel.Tags.Split(" ").ToList(),
|
||||||
|
ExtraFields = importModel.ExtraFields.Any() ? importModel.ExtraFields.Select(x => new ExtraField { Name = x.Key, Value = x.Value }).ToList() : new List<ExtraField>()
|
||||||
};
|
};
|
||||||
_serviceRecordDataAccess.SaveServiceRecordToVehicle(convertedRecord);
|
_serviceRecordDataAccess.SaveServiceRecordToVehicle(convertedRecord);
|
||||||
if (_config.GetUserConfig(User).EnableAutoOdometerInsert)
|
if (_config.GetUserConfig(User).EnableAutoOdometerInsert)
|
||||||
@ -518,7 +520,8 @@ namespace CarCareTracker.Controllers
|
|||||||
InitialMileage = string.IsNullOrWhiteSpace(importModel.InitialOdometer) ? 0 : decimal.ToInt32(decimal.Parse(importModel.InitialOdometer, NumberStyles.Any)),
|
InitialMileage = string.IsNullOrWhiteSpace(importModel.InitialOdometer) ? 0 : decimal.ToInt32(decimal.Parse(importModel.InitialOdometer, NumberStyles.Any)),
|
||||||
Mileage = decimal.ToInt32(decimal.Parse(importModel.Odometer, NumberStyles.Any)),
|
Mileage = decimal.ToInt32(decimal.Parse(importModel.Odometer, NumberStyles.Any)),
|
||||||
Notes = string.IsNullOrWhiteSpace(importModel.Notes) ? "" : importModel.Notes,
|
Notes = string.IsNullOrWhiteSpace(importModel.Notes) ? "" : importModel.Notes,
|
||||||
Tags = string.IsNullOrWhiteSpace(importModel.Tags) ? [] : importModel.Tags.Split(" ").ToList()
|
Tags = string.IsNullOrWhiteSpace(importModel.Tags) ? [] : importModel.Tags.Split(" ").ToList(),
|
||||||
|
ExtraFields = importModel.ExtraFields.Any() ? importModel.ExtraFields.Select(x => new ExtraField { Name = x.Key, Value = x.Value }).ToList() : new List<ExtraField>()
|
||||||
};
|
};
|
||||||
_odometerRecordDataAccess.SaveOdometerRecordToVehicle(convertedRecord);
|
_odometerRecordDataAccess.SaveOdometerRecordToVehicle(convertedRecord);
|
||||||
}
|
}
|
||||||
@ -537,7 +540,8 @@ namespace CarCareTracker.Controllers
|
|||||||
Priority = parsedPriority,
|
Priority = parsedPriority,
|
||||||
Description = string.IsNullOrWhiteSpace(importModel.Description) ? $"Plan Record on {importModel.DateCreated}" : importModel.Description,
|
Description = string.IsNullOrWhiteSpace(importModel.Description) ? $"Plan Record on {importModel.DateCreated}" : importModel.Description,
|
||||||
Notes = string.IsNullOrWhiteSpace(importModel.Notes) ? "" : importModel.Notes,
|
Notes = string.IsNullOrWhiteSpace(importModel.Notes) ? "" : importModel.Notes,
|
||||||
Cost = decimal.Parse(importModel.Cost, NumberStyles.Any)
|
Cost = decimal.Parse(importModel.Cost, NumberStyles.Any),
|
||||||
|
ExtraFields = importModel.ExtraFields.Any() ? importModel.ExtraFields.Select(x => new ExtraField { Name = x.Key, Value = x.Value }).ToList() : new List<ExtraField>()
|
||||||
};
|
};
|
||||||
_planRecordDataAccess.SavePlanRecordToVehicle(convertedRecord);
|
_planRecordDataAccess.SavePlanRecordToVehicle(convertedRecord);
|
||||||
}
|
}
|
||||||
@ -551,7 +555,8 @@ namespace CarCareTracker.Controllers
|
|||||||
Description = string.IsNullOrWhiteSpace(importModel.Description) ? $"Repair Record on {importModel.Date}" : importModel.Description,
|
Description = string.IsNullOrWhiteSpace(importModel.Description) ? $"Repair Record on {importModel.Date}" : importModel.Description,
|
||||||
Notes = string.IsNullOrWhiteSpace(importModel.Notes) ? "" : importModel.Notes,
|
Notes = string.IsNullOrWhiteSpace(importModel.Notes) ? "" : importModel.Notes,
|
||||||
Cost = decimal.Parse(importModel.Cost, NumberStyles.Any),
|
Cost = decimal.Parse(importModel.Cost, NumberStyles.Any),
|
||||||
Tags = string.IsNullOrWhiteSpace(importModel.Tags) ? [] : importModel.Tags.Split(" ").ToList()
|
Tags = string.IsNullOrWhiteSpace(importModel.Tags) ? [] : importModel.Tags.Split(" ").ToList(),
|
||||||
|
ExtraFields = importModel.ExtraFields.Any() ? importModel.ExtraFields.Select(x => new ExtraField { Name = x.Key, Value = x.Value }).ToList() : new List<ExtraField>()
|
||||||
};
|
};
|
||||||
_collisionRecordDataAccess.SaveCollisionRecordToVehicle(convertedRecord);
|
_collisionRecordDataAccess.SaveCollisionRecordToVehicle(convertedRecord);
|
||||||
if (_config.GetUserConfig(User).EnableAutoOdometerInsert)
|
if (_config.GetUserConfig(User).EnableAutoOdometerInsert)
|
||||||
@ -575,7 +580,8 @@ namespace CarCareTracker.Controllers
|
|||||||
Description = string.IsNullOrWhiteSpace(importModel.Description) ? $"Upgrade Record on {importModel.Date}" : importModel.Description,
|
Description = string.IsNullOrWhiteSpace(importModel.Description) ? $"Upgrade Record on {importModel.Date}" : importModel.Description,
|
||||||
Notes = string.IsNullOrWhiteSpace(importModel.Notes) ? "" : importModel.Notes,
|
Notes = string.IsNullOrWhiteSpace(importModel.Notes) ? "" : importModel.Notes,
|
||||||
Cost = decimal.Parse(importModel.Cost, NumberStyles.Any),
|
Cost = decimal.Parse(importModel.Cost, NumberStyles.Any),
|
||||||
Tags = string.IsNullOrWhiteSpace(importModel.Tags) ? [] : importModel.Tags.Split(" ").ToList()
|
Tags = string.IsNullOrWhiteSpace(importModel.Tags) ? [] : importModel.Tags.Split(" ").ToList(),
|
||||||
|
ExtraFields = importModel.ExtraFields.Any() ? importModel.ExtraFields.Select(x => new ExtraField { Name = x.Key, Value = x.Value }).ToList() : new List<ExtraField>()
|
||||||
};
|
};
|
||||||
_upgradeRecordDataAccess.SaveUpgradeRecordToVehicle(convertedRecord);
|
_upgradeRecordDataAccess.SaveUpgradeRecordToVehicle(convertedRecord);
|
||||||
if (_config.GetUserConfig(User).EnableAutoOdometerInsert)
|
if (_config.GetUserConfig(User).EnableAutoOdometerInsert)
|
||||||
@ -601,7 +607,8 @@ namespace CarCareTracker.Controllers
|
|||||||
Description = importModel.Description,
|
Description = importModel.Description,
|
||||||
Cost = decimal.Parse(importModel.Cost, NumberStyles.Any),
|
Cost = decimal.Parse(importModel.Cost, NumberStyles.Any),
|
||||||
Notes = importModel.Notes,
|
Notes = importModel.Notes,
|
||||||
Tags = string.IsNullOrWhiteSpace(importModel.Tags) ? [] : importModel.Tags.Split(" ").ToList()
|
Tags = string.IsNullOrWhiteSpace(importModel.Tags) ? [] : importModel.Tags.Split(" ").ToList(),
|
||||||
|
ExtraFields = importModel.ExtraFields.Any() ? importModel.ExtraFields.Select(x => new ExtraField { Name = x.Key, Value = x.Value }).ToList() : new List<ExtraField>()
|
||||||
};
|
};
|
||||||
_supplyRecordDataAccess.SaveSupplyRecordToVehicle(convertedRecord);
|
_supplyRecordDataAccess.SaveSupplyRecordToVehicle(convertedRecord);
|
||||||
}
|
}
|
||||||
@ -614,7 +621,8 @@ namespace CarCareTracker.Controllers
|
|||||||
Description = string.IsNullOrWhiteSpace(importModel.Description) ? $"Tax Record on {importModel.Date}" : importModel.Description,
|
Description = string.IsNullOrWhiteSpace(importModel.Description) ? $"Tax Record on {importModel.Date}" : importModel.Description,
|
||||||
Notes = string.IsNullOrWhiteSpace(importModel.Notes) ? "" : importModel.Notes,
|
Notes = string.IsNullOrWhiteSpace(importModel.Notes) ? "" : importModel.Notes,
|
||||||
Cost = decimal.Parse(importModel.Cost, NumberStyles.Any),
|
Cost = decimal.Parse(importModel.Cost, NumberStyles.Any),
|
||||||
Tags = string.IsNullOrWhiteSpace(importModel.Tags) ? [] : importModel.Tags.Split(" ").ToList()
|
Tags = string.IsNullOrWhiteSpace(importModel.Tags) ? [] : importModel.Tags.Split(" ").ToList(),
|
||||||
|
ExtraFields = importModel.ExtraFields.Any() ? importModel.ExtraFields.Select(x => new ExtraField { Name = x.Key, Value = x.Value }).ToList() : new List<ExtraField>()
|
||||||
};
|
};
|
||||||
_taxRecordDataAccess.SaveTaxRecordToVehicle(convertedRecord);
|
_taxRecordDataAccess.SaveTaxRecordToVehicle(convertedRecord);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -27,6 +27,18 @@ namespace CarCareTracker.MapProfile
|
|||||||
Map(m => m.Type).Name(["type"]);
|
Map(m => m.Type).Name(["type"]);
|
||||||
Map(m => m.Priority).Name(["priority"]);
|
Map(m => m.Priority).Name(["priority"]);
|
||||||
Map(m => m.Tags).Name(["tags"]);
|
Map(m => m.Tags).Name(["tags"]);
|
||||||
|
Map(m => m.ExtraFields).Convert(row =>
|
||||||
|
{
|
||||||
|
var attributes = new Dictionary<string, string>();
|
||||||
|
foreach (var header in row.Row.HeaderRecord)
|
||||||
|
{
|
||||||
|
if (header.ToLower().StartsWith("extrafield_"))
|
||||||
|
{
|
||||||
|
attributes.Add(header.Substring(11), row.Row.GetField(header));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return attributes;
|
||||||
|
}); ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -25,6 +25,7 @@
|
|||||||
public string PartSupplier { get; set; }
|
public string PartSupplier { get; set; }
|
||||||
public string PartQuantity { get; set; }
|
public string PartQuantity { get; set; }
|
||||||
public string Tags { get; set; }
|
public string Tags { get; set; }
|
||||||
|
public Dictionary<string,string> ExtraFields {get;set;}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class SupplyRecordExportModel
|
public class SupplyRecordExportModel
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user