Example #1
0
 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"));
            }
        }
Example #3
0
        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"));
            }
        }
Example #4
0
 public ParkedVehiclesController(Garage2_0Context context)
 {
     _context = context;
 }
Example #5
0
 public TypeSelectService(Garage2_0Context _context)
 {
     this._context = _context;
 }
 public ParkedVehiclesController(Garage2_0Context context)
 {
     _context    = context;
     parkingSlot = new ParkingSlots();
 }
Example #7
0
 public TypeSelectService(Garage2_0Context db)
 {
     this.db = db;
 }