예제 #1
0
 internal vwManager FindManagerCredentials(string userName, string password)
 {
     try
     {
         using (HotelServiceEntities context = new HotelServiceEntities())
         {
             string    encryptedPassword = EncryptionHelper.Encrypt(password);
             vwManager managerToFind     = (from m in context.vwManagers where m.UserName == userName && m.Password == encryptedPassword select m).First();
             return(managerToFind);
         }
     }
     catch (Exception ex)
     {
         System.Diagnostics.Debug.WriteLine("Manager not found." + ex.Message.ToString());
         return(null);
     }
 }
예제 #2
0
 internal vwManager AddManager(vwManager manager)
 {
     try
     {
         using (HotelServiceEntities context = new HotelServiceEntities())
         {
             tblUser newUser = new tblUser
             {
                 FullName    = manager.FullName,
                 DateOfBirth = manager.DateOfBirth,
                 Email       = manager.Email,
                 UserName    = manager.UserName,
                 Password    = manager.Password
             };
             context.tblUsers.Add(newUser);
             context.SaveChanges();
             manager.UserID = newUser.UserID;
             tblManager newManager = new tblManager
             {
                 FloorNumber      = manager.FloorNumber,
                 WorkExperience   = manager.WorkExperience,
                 LevelOfEducation = manager.LevelOfEducation,
                 UserID           = manager.UserID
             };
             context.tblManagers.Add(newManager);
             context.SaveChanges();
             manager.ManagerID = newManager.ManagerID;
             return(manager);
         }
     }
     catch (Exception ex)
     {
         System.Diagnostics.Debug.WriteLine("Exception" + ex.Message.ToString());
         return(null);
     }
 }