public async Task<bool> Update(VehicleColor item) { var color = await IdExist(item.Id); color.Name = item.Name; _db.Entry(color).State = EntityState.Modified; try { await _db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException exception) { throw new DbUpdateConcurrencyException(exception.Message); } return true; }
public async Task<VehicleColor> Add(VehicleColor item) { var newColor = new VehicleColor { Name = item.Name }; newColor = _db.VehicleColors.Add(newColor); try { await _db.SaveChangesAsync(); return newColor; } catch (DbUpdateConcurrencyException exception) { throw new DbUpdateConcurrencyException(exception.Message); } }