mirror of
https://github.com/hargata/lubelog.git
synced 2025-12-10 18:36:38 -06:00
added post methods for tax records.
This commit is contained in:
parent
e801a4a77c
commit
30a9411cdd
@ -109,6 +109,46 @@ namespace CarCareTracker.Controllers
|
|||||||
return Json(result);
|
return Json(result);
|
||||||
}
|
}
|
||||||
[TypeFilter(typeof(CollaboratorFilter))]
|
[TypeFilter(typeof(CollaboratorFilter))]
|
||||||
|
[HttpPost]
|
||||||
|
[Route("/api/vehicle/taxrecords/add")]
|
||||||
|
public IActionResult AddTaxRecord(int vehicleId, TaxRecordExportModel input)
|
||||||
|
{
|
||||||
|
var response = new OperationResponse();
|
||||||
|
if (vehicleId == default)
|
||||||
|
{
|
||||||
|
response.Success = false;
|
||||||
|
response.Message = "Must provide a valid vehicle id";
|
||||||
|
return Json(response);
|
||||||
|
}
|
||||||
|
if (string.IsNullOrWhiteSpace(input.Description))
|
||||||
|
{
|
||||||
|
response.Success = false;
|
||||||
|
response.Message = "Must provide a valid description";
|
||||||
|
return Json(response);
|
||||||
|
}
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var taxRecord = new TaxRecord()
|
||||||
|
{
|
||||||
|
VehicleId = vehicleId,
|
||||||
|
Date = DateTime.Parse(input.Date),
|
||||||
|
Description = input.Description,
|
||||||
|
Notes = string.IsNullOrWhiteSpace(input.Notes) ? "" : input.Notes,
|
||||||
|
Cost = decimal.Parse(input.Cost)
|
||||||
|
};
|
||||||
|
_taxRecordDataAccess.SaveTaxRecordToVehicle(taxRecord);
|
||||||
|
response.Success = true;
|
||||||
|
response.Message = "Tax Record Added";
|
||||||
|
return Json(response);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
response.Success = false;
|
||||||
|
response.Message = ex.Message;
|
||||||
|
return Json(response);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
[TypeFilter(typeof(CollaboratorFilter))]
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
[Route("/api/vehicle/odometerrecords")]
|
[Route("/api/vehicle/odometerrecords")]
|
||||||
public IActionResult OdometerRecords(int vehicleId)
|
public IActionResult OdometerRecords(int vehicleId)
|
||||||
@ -145,7 +185,7 @@ namespace CarCareTracker.Controllers
|
|||||||
} catch (Exception ex)
|
} catch (Exception ex)
|
||||||
{
|
{
|
||||||
response.Success = false;
|
response.Success = false;
|
||||||
response.Message = StaticHelper.GenericErrorMessage;
|
response.Message = ex.Message;
|
||||||
return Json(response);
|
return Json(response);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -53,7 +53,6 @@
|
|||||||
public class TaxRecordExportModel
|
public class TaxRecordExportModel
|
||||||
{
|
{
|
||||||
public string Date { get; set; }
|
public string Date { get; set; }
|
||||||
public string Odometer { get; set; }
|
|
||||||
public string Description { get; set; }
|
public string Description { get; set; }
|
||||||
public string Notes { get; set; }
|
public string Notes { get; set; }
|
||||||
public string Cost { get; set; }
|
public string Cost { get; set; }
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user