public void Save(User userModel)
 {
     using (var db = new UserDBContext())
     {
         db.Users.Add(userModel);
         db.SaveChanges();
     }
 }
        public bool Delete(int id)
        {
            using (var db = new UserDBContext())
            {
                User user = db.Users.Find(id);
                if (user == null)
                {
                    return(false);
                }

                db.Users.Remove(user);
                db.SaveChanges();

                return(true);
            }
        }
        public void Update(User user)
        {
            using (var db = new UserDBContext())
            {
                db.Entry(user).State = EntityState.Modified;

                try
                {
                    db.SaveChanges();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!UserExists(user.ID))
                    {
                        throw;
                    }
                    else
                    {
                        throw;
                    }
                }
            }
        }