Validate new logs are not being entered after vehicle is inactive.
This commit is contained in:
@@ -124,27 +124,32 @@ namespace MileageTraker.Web.ViewModels.Log
|
||||
if (LogType.Value == 0)
|
||||
yield return new ValidationResult("Required", new[] { "LogType" });
|
||||
|
||||
ValidationResult chronologyResult = null;
|
||||
try
|
||||
using (var dataService = new DataService())
|
||||
{
|
||||
using (var dataService = new DataService())
|
||||
ValidationResult chronologyResult = null;
|
||||
try
|
||||
{
|
||||
dataService.ValidateOdometerChronology(VehicleId, int.Parse(EndOdometer), Date);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
chronologyResult = new ValidationResult(ex.Message, new [] {"EndOdometer"});
|
||||
}
|
||||
if (chronologyResult != null)
|
||||
yield return chronologyResult;
|
||||
catch (Exception ex)
|
||||
{
|
||||
chronologyResult = new ValidationResult(ex.Message, new[] {"EndOdometer"});
|
||||
}
|
||||
if (chronologyResult != null)
|
||||
yield return chronologyResult;
|
||||
|
||||
using (var dataService = new DataService())
|
||||
{
|
||||
var user = dataService.FindUserByFullName(UserFullName);
|
||||
if (user == null)
|
||||
{
|
||||
yield return new ValidationResult("User with this name doesn't exist", new[] { "UserFullName" });
|
||||
yield return new ValidationResult("User with this name doesn't exist", new[] {"UserFullName"});
|
||||
}
|
||||
|
||||
var inactiveDate = dataService.GetVehicle(VehicleId).InactiveDate;
|
||||
if (inactiveDate.HasValue && Date.Date > inactiveDate)
|
||||
{
|
||||
yield return new ValidationResult(
|
||||
string.Format("Vehicle was set inactive on {0:MM/dd/yyyy}", inactiveDate.Value),
|
||||
new[] { "Date" });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user