public virtual async Task <TEntity> AddAsync(TEntity entity) { if (entity == null) { throw new ArgumentNullException($"{nameof(AddAsync)} entity must not be null"); } try { EntityEntry <TEntity> entry = await AirportContext.AddAsync(entity); await AirportContext.SaveChangesAsync(); return(entry.Entity); } catch (DbUpdateException dbEx) { throw new DbUpdateException($"Issue while saving to DB: {dbEx.Message}"); } catch (Exception ex) { throw new Exception($"{nameof(entity)} could not be saved: {ex.Message}"); } }
public async Task Create(Plane plane) { await db.AddAsync(plane); }