added default values for uploaded file. added validation so that filename is not null in bulk imports.
This commit is contained in:
@@ -124,8 +124,12 @@ namespace CarCareTracker.Controllers
|
|||||||
[HttpPost]
|
[HttpPost]
|
||||||
public IActionResult ImportToVehicleIdFromCsv(int vehicleId, string mode, string fileName)
|
public IActionResult ImportToVehicleIdFromCsv(int vehicleId, string mode, string fileName)
|
||||||
{
|
{
|
||||||
|
if (vehicleId == default || string.IsNullOrWhiteSpace(fileName))
|
||||||
|
{
|
||||||
|
return Json(false);
|
||||||
|
}
|
||||||
var fullFileName = _fileHelper.GetFullFilePath(fileName);
|
var fullFileName = _fileHelper.GetFullFilePath(fileName);
|
||||||
if (vehicleId == default || string.IsNullOrWhiteSpace(fullFileName))
|
if (string.IsNullOrWhiteSpace(fullFileName))
|
||||||
{
|
{
|
||||||
return Json(false);
|
return Json(false);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,6 @@
|
|||||||
public string Description { get; set; }
|
public string Description { get; set; }
|
||||||
public decimal Cost { get; set; }
|
public decimal Cost { get; set; }
|
||||||
public string Notes { get; set; }
|
public string Notes { get; set; }
|
||||||
public List<UploadedFiles> Files { get; set; }
|
public List<UploadedFiles> Files { get; set; } = new List<UploadedFiles>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,6 @@
|
|||||||
public string Description { get; set; }
|
public string Description { get; set; }
|
||||||
public decimal Cost { get; set; }
|
public decimal Cost { get; set; }
|
||||||
public string Notes { get; set; }
|
public string Notes { get; set; }
|
||||||
public List<UploadedFiles> Files { get; set; }
|
public List<UploadedFiles> Files { get; set; } = new List<UploadedFiles>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,6 @@
|
|||||||
public string Description { get; set; }
|
public string Description { get; set; }
|
||||||
public decimal Cost { get; set; }
|
public decimal Cost { get; set; }
|
||||||
public string Notes { get; set; }
|
public string Notes { get; set; }
|
||||||
public List<UploadedFiles> Files { get; set; }
|
public List<UploadedFiles> Files { get; set; } = new List<UploadedFiles>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,9 +16,15 @@
|
|||||||
<div class="alert alert-danger" role="alert">
|
<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.
|
Failure to format the data correctly can cause data corruption. Please make sure you make a copy of the local database before proceeding.
|
||||||
</div>
|
</div>
|
||||||
@if (Model == "gas")
|
@if (Model == "gasrecord")
|
||||||
{
|
{
|
||||||
<a class="btn btn-link" href="/defaults/gassample.csv" target="_blank">Download Sample</a>
|
<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>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
3
wwwroot/defaults/servicerecordsample.csv
Normal file
3
wwwroot/defaults/servicerecordsample.csv
Normal 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
|
||||||
|
3
wwwroot/defaults/taxrecordsample.csv
Normal file
3
wwwroot/defaults/taxrecordsample.csv
Normal 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
|
||||||
|
Reference in New Issue
Block a user