/// <summary> /// Save object to the EF6 database /// </summary> /// <param name="DB">EF6 database reference (if valid)</param> public void SaveToDb(DbReference DB) { if (string.IsNullOrWhiteSpace(Plate)) { throw new ArgumentException("Notebook Plate is empty or white space"); } if (string.IsNullOrWhiteSpace(Text)) { throw new ArgumentException("Notebook Text is empty or white space"); } else { DB.NotebookDb.Add(this); DB.SaveChanges(); } }
/// <summary> /// Save object to the EF6 database /// </summary> /// <param name="DB">EF6 database reference (if valid)</param> public void SaveToDb(DbReference DB) { if (string.IsNullOrWhiteSpace(PlateNumber)) { throw new ArgumentException("Fuelbook PlateNumber is null or white space"); } if (string.IsNullOrWhiteSpace(Description)) { throw new ArgumentException("Fuelbook Description is nul or empty"); } if (Cost <= 0) { throw new ArgumentOutOfRangeException("Fuelbook Cost equals zero or less"); } if (Price <= 0) { throw new ArgumentOutOfRangeException("Fuelbook Price equals zero or less"); } if (Litres <= 0) { throw new ArgumentOutOfRangeException("Fuelbook Litres equals zero or less"); } if (Distance <= 0) { throw new ArgumentOutOfRangeException("Fuelbook Distance equals zero or less"); } if (Consumption <= 0) { throw new ArgumentOutOfRangeException("Fuelbook Consumption equals zero or less"); } if (Area_City < 0 || Area_City > 100) { throw new ArgumentOutOfRangeException("Fuelbook Area_City not in <0,100> range"); } if (Area_Open < 0 || Area_Open > 100) { throw new ArgumentOutOfRangeException("Fuelbook Area_Open not in <0,100> range"); } else { DB.FuelDb.Add(this); DB.SaveChanges(); } }
/// <summary> /// Save object to the EF6 database /// </summary> /// <param name="DB">EF6 database reference (if valid)</param> public void SaveToDb(DbReference DB) { if (string.IsNullOrWhiteSpace(Plate)) { throw new ArgumentException("Repairbook Plate is null or white space"); } if (string.IsNullOrWhiteSpace(Text)) { throw new ArgumentException("Repairbook Text is null or white sapce"); } if (Price < 0) { throw new ArgumentOutOfRangeException("Repairbook Price equals zero or less"); } else { DB.RepairDb.Add(this); DB.SaveChanges(); } }
/// <summary> /// Save object to the EF6 database /// </summary> /// <param name="DB">EF6 database reference (if valid)</param> public void SaveToDb(DbReference DB) { if (string.IsNullOrWhiteSpace(this.PlateNumber)) { throw new ArgumentException("Car Platenumber is null or white space"); } if (string.IsNullOrWhiteSpace(this.DisplayName)) { throw new ArgumentException("Car Username is null or white space"); } if (string.IsNullOrWhiteSpace(this.Password)) { throw new ArgumentException("User Password is null or white space"); } if (FuelCapacity <= 0) { throw new ArgumentOutOfRangeException("Car FuelCapacity is equal or lower than 0"); } if (string.IsNullOrWhiteSpace(this.Manufacturer)) { throw new ArgumentException("Car Manufacturer is null or white space"); } if (string.IsNullOrWhiteSpace(this.Model)) { throw new ArgumentException("Car Model is null or white space"); } if (this.Year < 1800) { throw new ArgumentOutOfRangeException("Car Year is lower than 1800"); } if (string.IsNullOrWhiteSpace(this.VinNumber)) { throw new ArgumentException("Car VIN is null or white space"); } else { DB.CarDb.Add(this); DB.SaveChanges(); } }