/// <summary> /// Adds the record to the database /// </summary> /// <param name="race">A Race model</param> public async Task AddAsync(Race race) { try { await _context.AddAsync(race); await _context.SaveChangesAsync(); } catch (Exception ex) { throw; // In here we would log the exception and return an error message to the user } }
/// <summary> /// Adds the record to the database /// </summary> /// <param name="vehicle">A Vehicle model</param> public async Task AddAsync(Vehicle vehicle) { try { if (string.IsNullOrEmpty(vehicle.VehicleAlias)) { vehicle.VehicleAlias = vehicle.OwnerName + "'s " + vehicle.Make + " " + vehicle.Model; } await _context.AddAsync(vehicle); await _context.SaveChangesAsync(); } catch (Exception ex) { throw; // In here we would log the exception and return an error message to the user } }