added default values for uploaded file. added validation so that filename is not null in bulk imports.

This commit is contained in:
ivancheahhh
2024-01-04 17:07:36 -07:00
parent e856e9d6ba
commit 9ad5039823
7 changed files with 21 additions and 5 deletions

View File

@@ -124,8 +124,12 @@ namespace CarCareTracker.Controllers
[HttpPost]
public IActionResult ImportToVehicleIdFromCsv(int vehicleId, string mode, string fileName)
{
if (vehicleId == default || string.IsNullOrWhiteSpace(fileName))
{
return Json(false);
}
var fullFileName = _fileHelper.GetFullFilePath(fileName);
if (vehicleId == default || string.IsNullOrWhiteSpace(fullFileName))
if (string.IsNullOrWhiteSpace(fullFileName))
{
return Json(false);
}

View File

@@ -9,6 +9,6 @@
public string Description { get; set; }
public decimal Cost { get; set; }
public string Notes { get; set; }
public List<UploadedFiles> Files { get; set; }
public List<UploadedFiles> Files { get; set; } = new List<UploadedFiles>();
}
}

View File

@@ -9,6 +9,6 @@
public string Description { get; set; }
public decimal Cost { get; set; }
public string Notes { get; set; }
public List<UploadedFiles> Files { get; set; }
public List<UploadedFiles> Files { get; set; } = new List<UploadedFiles>();
}
}

View File

@@ -8,6 +8,6 @@
public string Description { get; set; }
public decimal Cost { get; set; }
public string Notes { get; set; }
public List<UploadedFiles> Files { get; set; }
public List<UploadedFiles> Files { get; set; } = new List<UploadedFiles>();
}
}

View File

@@ -16,9 +16,15 @@
<div class="alert alert-danger" role="alert">
Failure to format the data correctly can cause data corruption. Please make sure you make a copy of the local database before proceeding.
</div>
@if (Model == "gas")
@if (Model == "gasrecord")
{
<a class="btn btn-link" href="/defaults/gassample.csv" target="_blank">Download Sample</a>
} else if (Model == "servicerecord" || Model == "repairrecord")
{
<a class="btn btn-link" href="/defaults/servicerecordsample.csv" target="_blank">Download Sample</a>
} else if (Model == "taxrecord")
{
<a class="btn btn-link" href="/defaults/taxrecordsample.csv" target="_blank">Download Sample</a>
}
</div>
</div>

View File

@@ -0,0 +1,3 @@
Date,Odometer,Description,Notes,Cost
01/01/2020,45000,Test Description 1,Test Note 1,20.60
01/02/2020,47000,Test Description 2,Test Note 2,40.45
1 Date Odometer Description Notes Cost
2 01/01/2020 45000 Test Description 1 Test Note 1 20.60
3 01/02/2020 47000 Test Description 2 Test Note 2 40.45

View File

@@ -0,0 +1,3 @@
Date,Description,Notes,Cost
01/01/2020,Test Description 1,Test Note 1,20.60
01/02/2020,Test Description 2,Test Note 2,40.45
1 Date Description Notes Cost
2 01/01/2020 Test Description 1 Test Note 1 20.60
3 01/02/2020 Test Description 2 Test Note 2 40.45