Пример #1
0
 public List <User> GetUsersList()
 {
     using (PenggunaEntities1 entities = new PenggunaEntities1())
     {
         return(entities.User.ToList());
     }
 }
Пример #2
0
 public void AddUser(string name, string email, string password)
 {
     using (PenggunaEntities1 entities = new PenggunaEntities1())
     {
         User book = new User {
             name = name, email = email, password = password
         };
         entities.User.Add(book);
         entities.SaveChanges();
     }
 }
Пример #3
0
        public void UpdateUser(UserComposite usr)
        {
            int UserId = Convert.ToInt32(usr.Id);

            using (PenggunaEntities1 entities = new PenggunaEntities1())
            {
                User wow = entities.User.SingleOrDefault(b => b.id == UserId);
                wow.name     = usr.Name;
                wow.email    = usr.Email;
                wow.password = usr.Password;
                entities.SaveChanges();
            }
        }
Пример #4
0
 public User GetUserById(string id)
 {
     try
     {
         int UserId = Convert.ToInt32(id);
         using (PenggunaEntities1 entities = new PenggunaEntities1())
         {
             return(entities.User.SingleOrDefault(User => User.id == UserId));
         }
     }
     catch
     {
         throw new FaultException(" Something went wrong");
     }
 }
Пример #5
0
 public void DeleteUser(string id)
 {
     try
     {
         int UserId = Convert.ToInt32(id);
         using (PenggunaEntities1 entities = new PenggunaEntities1())
         {
             User User = entities.User.SingleOrDefault(b => b.id == UserId);
             entities.User.Remove(User);
             entities.SaveChanges();
         }
     }
     catch
     {
         throw new FaultException("Something went wrong");
     }
 }
Пример #6
0
 public bool IsValid(string em, string ps)
 {
     try
     {
         string UserName = em;
         string UserPass = ps;
         using (PenggunaEntities1 entities = new PenggunaEntities1())
         {
             var query = (from c in entities.User
                          where c.email == em && c.password == ps
                          select c
                          ).Any();
             return(query);
         }
     }
     catch
     {
         throw new FaultException("Something went wrong");
     }
 }