Ejemplo n.º 1
0
 public bool createUser(UsersAdModel newUser)
 {
     try
     {
         user user = new user();
         user.display_name  = newUser.display_name;
         user.gender        = newUser.gender;
         user.date_of_birth = newUser.date_of_birth;
         user.phone_number  = newUser.phone_number;
         user.address       = newUser.address;
         user.email         = newUser.email;
         user.password      = new Utils().GetMd5Hash(newUser.password);
         user.status        = true;
         user.start_time    = DateTime.Now;
         db.users.Add(user);
         db.SaveChanges();
         return(true);
     }catch (Exception e)
     {
         return(false);
     }
 }
Ejemplo n.º 2
0
 public bool updateUserById(int id, UsersAdModel updateUser)
 {
     try
     {
         var currentUser = this.getUserById(id);
         if (currentUser != null)
         {
             currentUser.display_name    = updateUser.display_name;
             currentUser.gender          = updateUser.gender;
             currentUser.date_of_birth   = updateUser.date_of_birth;
             currentUser.phone_number    = updateUser.phone_number;
             currentUser.address         = updateUser.address;
             db.Entry(currentUser).State = System.Data.Entity.EntityState.Modified;
             db.SaveChanges();
             return(true);
         }
         return(false);
     }catch (Exception e)
     {
         return(false);
     }
 }