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