Exemplo n.º 1
0
 public List <User> GetUserList()
 {
     using (UserEntities entities = new UserEntities())
     {
         return(entities.User.ToList());
     }
 }
Exemplo n.º 2
0
 public User GetUserById(string id)
 {
     try
     {
         int UserId = Convert.ToInt32(id);
         using (UserEntities entities = new UserEntities())
         {
             return(entities.User.SingleOrDefault(User => User.id == UserId));
         }
     }
     catch
     {
         throw new FaultException("Something went wrong");
     }
 }
Exemplo n.º 3
0
 public void DeleteUser(string id)
 {
     try
     {
         int UserID = Convert.ToInt32(id);
         using (UserEntities entities = new UserEntities())
         {
             User user = entities.User.SingleOrDefault(b => b.id == UserID);
             entities.User.Remove(user);
         }
     }
     catch
     {
         throw new FaultException("Something went wrong");
     }
 }
Exemplo n.º 4
0
 public bool IsValid(string em, string ps)
 {
     try
     {
         using (UserEntities entities = new UserEntities())
         {
             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");
     }
 }
Exemplo n.º 5
0
 public void AddUser(string Name, string Email, string Password)
 {
     using (UserEntities entities = new UserEntities())
     {
         try
         {
             User user = new User {
                 name = Name, email = Email, password = Password
             };
             entities.User.Add(user);
             entities.SaveChanges();
         }
         catch
         {
             throw new FaultException("Something went wrong");
         }
     }
 }
Exemplo n.º 6
0
 //take all class on function
 public void UpdateUser(UserComposite usr)
 {
     try
     {
         int UserID = Convert.ToInt32(usr.Id);
         using (UserEntities entities = new UserEntities())
         {
             User wow = entities.User.SingleOrDefault(b => b.id == UserID);
             wow.name     = usr.Name;
             wow.email    = usr.Email;
             wow.password = usr.Password;
             entities.SaveChanges();
         }
     }
     catch
     {
         throw new FaultException("Something went wrong");
     }
 }