public int Update(Foodie foodie) { Foodie foodieToUpdate = (Foodie)_context.Foodies.SingleOrDefault(e => e.UserId == foodie.UserId); foreach (PropertyInfo property in typeof(Foodie).GetProperties()) { property.SetValue(foodieToUpdate, property.GetValue(foodie, null), null); } return(_context.SaveChanges()); }
public int Delete(int id) { Foodie foodieToDelete = _context.Foodies.SingleOrDefault(e => e.UserId == id); if (foodieToDelete != null) { _context.Foodies.Remove(foodieToDelete); } return(_context.SaveChanges()); }
public int Insert(Foodie foodie) { this._context.Foodies.Add(foodie); return(this._context.SaveChanges()); }