예제 #1
0
        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());
        }
예제 #2
0
        public int Delete(int id)
        {
            Foodie foodieToDelete = _context.Foodies.SingleOrDefault(e => e.UserId == id);

            if (foodieToDelete != null)
            {
                _context.Foodies.Remove(foodieToDelete);
            }

            return(_context.SaveChanges());
        }
예제 #3
0
        public int Insert(Foodie foodie)
        {
            this._context.Foodies.Add(foodie);

            return(this._context.SaveChanges());
        }