public int SaveItem(DatabaseContext _dbContext) { if (this.Id > 0) { CarTypes _item = _dbContext.CarTypes.Find(this.Id); _item.Name = this.Name; _dbContext.Entry(_item).State = EntityState.Modified; } else { _dbContext.CarTypes.Add(this); } return(_dbContext.SaveChanges()); }