Added Confirmation before deleting vehicle, started work on collisions.
This commit is contained in:
14
Models/CollisionRecord.cs
Normal file
14
Models/CollisionRecord.cs
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
namespace CarCareTracker.Models
|
||||||
|
{
|
||||||
|
public class CollisionRecord
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
public int VehicleId { get; set; }
|
||||||
|
public DateTime Date { get; set; }
|
||||||
|
public int Mileage { get; set; }
|
||||||
|
public string Description { get; set; }
|
||||||
|
public decimal Cost { get; set; }
|
||||||
|
public string Notes { get; set; }
|
||||||
|
public List<UploadedFiles> Files { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
15
Models/CollisionRecordInput.cs
Normal file
15
Models/CollisionRecordInput.cs
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
namespace CarCareTracker.Models
|
||||||
|
{
|
||||||
|
public class CollisionRecordInput
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
public int VehicleId { get; set; }
|
||||||
|
public string Date { get; set; }
|
||||||
|
public int Mileage { get; set; }
|
||||||
|
public string Description { get; set; }
|
||||||
|
public decimal Cost { get; set; }
|
||||||
|
public string Notes { get; set; }
|
||||||
|
public List<UploadedFiles> Files { get; set; } = new List<UploadedFiles>();
|
||||||
|
public CollisionRecord ToServiceRecord() { return new CollisionRecord { Id = Id, VehicleId = VehicleId, Date = DateTime.Parse(Date), Cost = Cost, Mileage = Mileage, Description = Description, Notes = Notes, Files = Files }; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -32,7 +32,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="modal fade" id="addVehicleModal" tabindex="-1" role="dialog" aria-labelledby="addVehicleModalLabel" aria-hidden="true">
|
<div class="modal fade" id="addVehicleModal" tabindex="-1" role="dialog">
|
||||||
<div class="modal-dialog" role="document">
|
<div class="modal-dialog" role="document">
|
||||||
<div class="modal-content" id="addVehicleModalContent">
|
<div class="modal-content" id="addVehicleModalContent">
|
||||||
|
|
||||||
|
|||||||
@@ -13,8 +13,7 @@
|
|||||||
<button onclick="returnToGarage()" class="btn btn-secondary btn-md mt-1 mb-1"><i class="bi bi-arrow-left-square"></i></button>
|
<button onclick="returnToGarage()" class="btn btn-secondary btn-md mt-1 mb-1"><i class="bi bi-arrow-left-square"></i></button>
|
||||||
<h1 class="text-truncate">@($"{Model.Year} {Model.Make} {Model.Model}(License # {Model.LicensePlate})")</h1>
|
<h1 class="text-truncate">@($"{Model.Year} {Model.Make} {Model.Model}(License # {Model.LicensePlate})")</h1>
|
||||||
<div class="btn-group">
|
<div class="btn-group">
|
||||||
<button onclick="showEditVehicleModal()" class="btn btn-secondary btn-md mt-1 mb-1"><i class="bi bi-pencil-square"></i></button>
|
<button onclick="editVehicle(@Model.Id)" class="btn btn-warning btn-md mt-1 mb-1"><i class="bi bi-pencil-square"></i></button>
|
||||||
<button onclick="DeleteVehicle(@Model.Id)" class="btn btn-danger btn-md mt-1 mb-1"><i class="bi bi-trash"></i></button>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -30,10 +29,10 @@
|
|||||||
<button class="nav-link" id="tax-tab" data-bs-toggle="tab" data-bs-target="#tax-tab-pane" type="button" role="tab" aria-selected="false"><i class="bi bi-currency-dollar me-2"></i>Taxes</button>
|
<button class="nav-link" id="tax-tab" data-bs-toggle="tab" data-bs-target="#tax-tab-pane" type="button" role="tab" aria-selected="false"><i class="bi bi-currency-dollar me-2"></i>Taxes</button>
|
||||||
</li>
|
</li>
|
||||||
<li class="nav-item" role="presentation">
|
<li class="nav-item" role="presentation">
|
||||||
<button class="nav-link" id="notes-tab" data-bs-toggle="tab" data-bs-target="#notes-tab-pane" type="button" role="tab" aria-selected="false"><i class="bi bi-journal-bookmark me-2"></i>Notes</button>
|
<button class="nav-link" id="accident-tab" data-bs-toggle="tab" data-bs-target="#accident-tab-pane" type="button" role="tab" aria-selected="false"><i class="bi bi-exclamation-octagon me-2"></i>Collisions</button>
|
||||||
</li>
|
</li>
|
||||||
<li class="nav-item" role="presentation">
|
<li class="nav-item" role="presentation">
|
||||||
<button class="nav-link" id="accident-tab" data-bs-toggle="tab" data-bs-target="#accident-tab-pane" type="button" role="tab" aria-selected="false"><i class="bi bi-exclamation-octagon me-2"></i>Collisions</button>
|
<button class="nav-link" id="notes-tab" data-bs-toggle="tab" data-bs-target="#notes-tab-pane" type="button" role="tab" aria-selected="false"><i class="bi bi-journal-bookmark me-2"></i>Notes</button>
|
||||||
</li>
|
</li>
|
||||||
<li class="nav-item ms-auto" role="presentation">
|
<li class="nav-item ms-auto" role="presentation">
|
||||||
<button class="nav-link" id="manage-tab" data-bs-toggle="tab" data-bs-target="#manage-tab-pane" type="button" role="tab" aria-selected="false"><i class="bi bi-wrench me-2"></i>Manage Vehicle</button>
|
<button class="nav-link" id="manage-tab" data-bs-toggle="tab" data-bs-target="#manage-tab-pane" type="button" role="tab" aria-selected="false"><i class="bi bi-wrench me-2"></i>Manage Vehicle</button>
|
||||||
@@ -59,7 +58,19 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="tab-pane fade" id="accident-tab-pane" role="tabpanel" tabindex="0">333</div>
|
<div class="tab-pane fade" id="accident-tab-pane" role="tabpanel" tabindex="0">333</div>
|
||||||
<div class="tab-pane fade" id="manage-tab-pane" role="tabpanel" tabindex="0">...</div>
|
<div class="tab-pane fade" id="manage-tab-pane" role="tabpanel" tabindex="0">
|
||||||
|
<div class="row">
|
||||||
|
<div class="d-flex justify-content-center">
|
||||||
|
<button onclick="deleteVehicle(@Model.Id)" class="btn btn-danger btn-md mt-1 mb-1"><i class="bi bi-trash me-2"></i>Delete Vehicle</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="modal fade" id="editVehicleModal" tabindex="-1" role="dialog">
|
||||||
|
<div class="modal-dialog" role="document">
|
||||||
|
<div class="modal-content" id="editVehicleModalContent">
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<script>
|
<script>
|
||||||
|
|||||||
@@ -13,7 +13,7 @@
|
|||||||
<span class="ms-2 badge bg-success">@($"Total Cost: {Model.Sum(x => x.Cost).ToString("C")}")</span>
|
<span class="ms-2 badge bg-success">@($"Total Cost: {Model.Sum(x => x.Cost).ToString("C")}")</span>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<button onclick="showAddGasRecordModal()" class="btn btn-primary btn-md mt-1 mb-1"><i class="bi bi-pencil-square"></i>Add Gas Record</button>
|
<button onclick="showAddGasRecordModal()" class="btn btn-primary btn-md mt-1 mb-1"><i class="bi bi-pencil-square me-2"></i>Add Gas Record</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
<span class="ms-2 badge bg-primary">@($"Total: {Model.Sum(x => x.Cost).ToString("C")}")</span>
|
<span class="ms-2 badge bg-primary">@($"Total: {Model.Sum(x => x.Cost).ToString("C")}")</span>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<button onclick="showAddServiceRecordModal()" class="btn btn-primary btn-md mt-1 mb-1"><i class="bi bi-pencil-square"></i>Add Service Record</button>
|
<button onclick="showAddServiceRecordModal()" class="btn btn-primary btn-md mt-1 mb-1"><i class="bi bi-pencil-square me-2"></i>Add Service Record</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -12,7 +12,7 @@
|
|||||||
<form class="form-inline">
|
<form class="form-inline">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="inputYear">Year</label>
|
<label for="inputYear">Year</label>
|
||||||
<input type="number" id="inputYear" class="form-control" value="@Model.Year">
|
<input type="number" id="inputYear" class="form-control" value="@(Model.Year > 0 ? Model.Year : "")">
|
||||||
<label for="inputMake">Make</label>
|
<label for="inputMake">Make</label>
|
||||||
<input type="text" id="inputMake" class="form-control" value="@Model.Make">
|
<input type="text" id="inputMake" class="form-control" value="@Model.Make">
|
||||||
<label for="inputModel">Model</label>
|
<label for="inputModel">Model</label>
|
||||||
@@ -32,12 +32,13 @@
|
|||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-footer">
|
<div class="modal-footer">
|
||||||
<button type="button" class="btn btn-secondary" onclick="hideAddVehicleModal()">Cancel</button>
|
|
||||||
@if (Model.Id == 0)
|
@if (Model.Id == 0)
|
||||||
{
|
{
|
||||||
|
<button type="button" class="btn btn-secondary" onclick="hideAddVehicleModal()">Cancel</button>
|
||||||
<button type="button" onclick="saveVehicle(false)" class="btn btn-primary">Add New Vehicle</button>
|
<button type="button" onclick="saveVehicle(false)" class="btn btn-primary">Add New Vehicle</button>
|
||||||
} else if (Model.Id > 0)
|
} else if (Model.Id > 0)
|
||||||
{
|
{
|
||||||
|
<button type="button" class="btn btn-secondary" onclick="hideEditVehicleModal()">Cancel</button>
|
||||||
<button type="button" onclick="saveVehicle(true)" class="btn btn-primary">Save Vehicle</button>
|
<button type="button" onclick="saveVehicle(true)" class="btn btn-primary">Save Vehicle</button>
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -76,11 +76,13 @@ function saveVehicle(isEdit) {
|
|||||||
}, function (data) {
|
}, function (data) {
|
||||||
if (data) {
|
if (data) {
|
||||||
if (!isEdit) {
|
if (!isEdit) {
|
||||||
successToast("Vehicle added");
|
successToast("Vehicle Added");
|
||||||
hideAddVehicleModal();
|
hideAddVehicleModal();
|
||||||
loadGarage();
|
loadGarage();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
successToast("Vehicle Updated");
|
||||||
|
hideEditVehicleModal();
|
||||||
viewVehicle(vehicleId);
|
viewVehicle(vehicleId);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -49,12 +49,33 @@ function getVehicleServiceRecords(vehicleId) {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
function DeleteVehicle(vehicleId) {
|
function editVehicle(vehicleId) {
|
||||||
$.post('/Vehicle/DeleteVehicle', { vehicleId: vehicleId }, function (data) {
|
$.get(`/Vehicle/GetEditVehiclePartialViewById?vehicleId=${vehicleId}`, function (data) {
|
||||||
if (data) {
|
if (data) {
|
||||||
window.location.href = '/Home';
|
$("#editVehicleModalContent").html(data);
|
||||||
|
$('#editVehicleModal').modal('show');
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
|
}
|
||||||
|
function hideEditVehicleModal() {
|
||||||
|
$('#editVehicleModal').modal('hide');
|
||||||
|
}
|
||||||
|
function deleteVehicle(vehicleId) {
|
||||||
|
Swal.fire({
|
||||||
|
title: "Confirm Deletion?",
|
||||||
|
text: "This will also delete all data tied to this vehicle. Deleted Vehicles and their associated data cannot be restored.",
|
||||||
|
showCancelButton: true,
|
||||||
|
confirmButtonText: "Delete",
|
||||||
|
confirmButtonColor: "#dc3545"
|
||||||
|
}).then((result) => {
|
||||||
|
if (result.isConfirmed) {
|
||||||
|
$.post('/Vehicle/DeleteVehicle', { vehicleId: vehicleId }, function (data) {
|
||||||
|
if (data) {
|
||||||
|
window.location.href = '/Home';
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
function getVehicleGasRecords(vehicleId) {
|
function getVehicleGasRecords(vehicleId) {
|
||||||
$.get(`/Vehicle/GetGasRecordsByVehicleId?vehicleId=${vehicleId}`, function (data) {
|
$.get(`/Vehicle/GetGasRecordsByVehicleId?vehicleId=${vehicleId}`, function (data) {
|
||||||
|
|||||||
Reference in New Issue
Block a user