コード例 #1
0
        public int Update(RestaurantAdmin restaurantAdmin)
        {
            RestaurantAdmin restaurantAdminToUpdate = _context.RestaurantAdmins.SingleOrDefault(e => e.UserId == restaurantAdmin.UserId);

            foreach (PropertyInfo property in typeof(RestaurantAdmin).GetProperties())
            {
                property.SetValue(restaurantAdminToUpdate, property.GetValue(restaurantAdmin, null), null);
            }

            return(_context.SaveChanges());
        }
コード例 #2
0
        public int Delete(int id)
        {
            RestaurantAdmin restaurantAdminToDelete = _context.RestaurantAdmins.SingleOrDefault(e => e.UserId == id);

            if (restaurantAdminToDelete != null)
            {
                _context.RestaurantAdmins.Remove(restaurantAdminToDelete);
            }

            return(_context.SaveChanges());
        }
コード例 #3
0
        public int Insert(RestaurantAdmin restaurantAdmin)
        {
            _context.RestaurantAdmins.Add(restaurantAdmin);

            return(_context.SaveChanges());
        }