Nearing feature complete for driver auth
This commit is contained in:
+4
-31
@@ -2,7 +2,6 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Web.Mvc;
|
||||
using MileageTraker.Web.Attributes;
|
||||
using MileageTraker.Web.DAL;
|
||||
|
||||
namespace MileageTraker.Web.Models
|
||||
@@ -10,58 +9,33 @@ namespace MileageTraker.Web.Models
|
||||
public class Log : IValidatableObject
|
||||
{
|
||||
[Key]
|
||||
[HiddenInput(DisplayValue = false)]
|
||||
public int LogId { get; set; }
|
||||
|
||||
[Required]
|
||||
[Remote("Exists", "Vehicle", ErrorMessage = "ID not found")]
|
||||
[StringLength(6, MinimumLength = 4, ErrorMessage = "Enter 4 digit number")]
|
||||
[Display(Name = "Vehicle ID")]
|
||||
[InputSize("mini")]
|
||||
[RegularExpression(@"\d+", ErrorMessage = "Enter only numbers")]
|
||||
public string VehicleId { get; set; }
|
||||
|
||||
[Required]
|
||||
[Range(1, 500000, ErrorMessage = "Between 1 and 500k")]
|
||||
[Display(Name = "End Odometer")]
|
||||
[InputSize("small")]
|
||||
[Units("Miles")]
|
||||
public int EndOdometer { get; set; }
|
||||
|
||||
[Required]
|
||||
[Display(Name = "Type")]
|
||||
[NoEditLabel]
|
||||
public MileageLogTypeWrapper LogType { get; set; }
|
||||
|
||||
[Required]
|
||||
[StringLength(64, MinimumLength = 3, ErrorMessage = "Minimum 3 characters")]
|
||||
[InputSize("medium")]
|
||||
public string CityName { get; set; }
|
||||
|
||||
//[Required]
|
||||
//[Display(Name = "Employee / Driver")]
|
||||
//[RegularExpression(@"[A-Za-z().]+(\s+[A-Za-z().]+)+", ErrorMessage = "Need complete name")]
|
||||
//[InputSize("medium")]
|
||||
//public string EmployeeName { get; set; }
|
||||
|
||||
[Required]
|
||||
[Display(Name = "Employee / Driver")]
|
||||
[HiddenInput(DisplayValue = false)]
|
||||
public virtual User User { get; set; }
|
||||
|
||||
[Range(0, 50)]
|
||||
[DisplayFormat(DataFormatString = "{0:0.000}", ApplyFormatInEditMode = true)]
|
||||
[Units("Gallons")]
|
||||
[FormatHint("n.nnnn")]
|
||||
[InputSize("mini")]
|
||||
public double GasPurchased { get; set; }
|
||||
|
||||
[Required]
|
||||
[DataType(DataType.Date)]
|
||||
[DisplayFormat(DataFormatString = @"{0:MM/dd/yyyy}", ApplyFormatInEditMode = true)]
|
||||
[DenyFutureDate(ErrorMessage = "Future date")]
|
||||
[FormatHint("mm/dd/yyyy")]
|
||||
[InputSize("small")]
|
||||
public DateTime Date { get; set; }
|
||||
|
||||
[Display(Name = "Time Created")]
|
||||
@@ -72,13 +46,10 @@ namespace MileageTraker.Web.Models
|
||||
/// <summary>
|
||||
/// url route that was used to create this instance, ie 'CreateLog\Confirm' or 'Logs\Create'
|
||||
/// </summary>
|
||||
[HiddenInput(DisplayValue = false)]
|
||||
public string Source { get; set; }
|
||||
|
||||
[HiddenInput(DisplayValue = false)]
|
||||
public string UserHostAddress { get; set; }
|
||||
|
||||
[HiddenInput(DisplayValue = false)]
|
||||
public string UserAgent { get; set; }
|
||||
|
||||
[HiddenInput(DisplayValue = false)]
|
||||
@@ -103,8 +74,10 @@ namespace MileageTraker.Web.Models
|
||||
ValidationResult result = null;
|
||||
try
|
||||
{
|
||||
var dataService = new DataService();
|
||||
dataService.ValidateOdometerChronology(VehicleId, EndOdometer, Date);
|
||||
using (var dataService = new DataService())
|
||||
{
|
||||
dataService.ValidateOdometerChronology(VehicleId, EndOdometer, Date);
|
||||
}
|
||||
}
|
||||
catch (ChronologicalOrderException ex)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user