protected override void Seed(Garage2_0Context context) { //context.VehicleTypes.AddOrUpdate( // new VehicleType { Type = "Car" }, // new VehicleType { Type = "Van" }, // new VehicleType { Type = "Truck" }, // new VehicleType { Type = "Motorcycle" } // ); }
protected override ValidationResult IsValid(object regnumInput, ValidationContext validationContext) { try { Garage2_0Context db = new Garage2_0Context(); Vehicle vehicle = (Vehicle)validationContext.ObjectInstance; var result = db.Vehicles.FirstOrDefault(v => v.RegNum == regnumInput.ToString() && v.Id != vehicle.Id); if (result == null) { return(ValidationResult.Success); } else { return(new ValidationResult("This registration number already exists")); } } catch (Exception) { return(new ValidationResult("Invalid input")); } }
protected override ValidationResult IsValid(object memberIdInput, ValidationContext validationContext) { try { Garage2_0Context db = new Garage2_0Context(); Vehicle vehicle = (Vehicle)validationContext.ObjectInstance; var result = db.Members.FirstOrDefault(v => v.MembershipNr == vehicle.MembershipNr); if (result == null) { return(new ValidationResult("Could not find customer with that ID")); } else { return(ValidationResult.Success); } } catch (Exception) { return(new ValidationResult("Invalid input")); } }
public ParkedVehiclesController(Garage2_0Context context) { _context = context; }
public TypeSelectService(Garage2_0Context _context) { this._context = _context; }
public ParkedVehiclesController(Garage2_0Context context) { _context = context; parkingSlot = new ParkingSlots(); }
public TypeSelectService(Garage2_0Context db) { this.db = db; }