public async Task <Car> CreateItemAsync(UpdateCarRequest updateRequest) { var res = updateRequest.Map(); await this.context.Cars.AddAsync(res); await this.context.SaveChangesAsync(); return(res); }
public async Task <Car> UpdateItemAsync(int id, UpdateCarRequest updateRequest) { var res = await this.context.Cars.SingleOrDefaultAsync(item => item.CarId == id); if (res == null) { throw new CarNotFoundException($"{id} not found."); } res = updateRequest.Map(); await this.context.SaveChangesAsync(); return(res); }