Beispiel #1
0
 public User SignUp(string name, string address, string password, string creditCard)
 {
     try
     {
         MarketLog.Log("UserSpot", "User " + currentID + " attempting to sign up to the system...");
         ApproveSignUp(name, address, password, creditCard);
         string encryptedPassword = UserSecurityService.ToEncryptPassword(_guest.SystemID, password);
         MarketLog.Log("UserSpot", "Searching for existing user and storing newly Registered User "
                       + currentID + " data...");
         ValidateUserNotExist(name);
         RegisteredUser newRegistered = _userDB.RegisterUser(_guest.SystemID, name, address, encryptedPassword,
                                                             creditCard, _guest.Cart.GetCartStorage());
         MarketLog.Log("UserSpot", "User " + newRegistered.SystemID + " sign up to the system has been successfull!");
         Answer = new UserAnswer(SignUpStatus.Success, "Sign up has been successfull!");
         _publisher.AddFeedQueue(newRegistered.SystemID);
         return(newRegistered);
     }
     catch (UserException e)
     {
         Answer = new UserAnswer((SignUpStatus)e.Status, e.GetErrorMessage());
         return(_guest);
     }
     catch (DataException e)
     {
         Answer = new UserAnswer((SignUpStatus)e.Status, e.GetErrorMessage());
         return(_guest);
     }
 }
Beispiel #2
0
 public User SignIn(string name, string password)
 {
     try
     {
         MarketLog.Log("UserSpot", "User " + guestID + " attempting to sign in the system...");
         ApproveSignIn(name, password);
         string encryptedPassword = UserSecurityService.ToEncryptPassword(_guest.SystemID, password);
         MarketLog.Log("UserSpot", "Searching for existing user and logging in Guest "
                       + guestID + " into the system...");
         object[] userData   = ValidateUserExist(name, encryptedPassword);
         User     loggedUser = _userDB.LoadUser(userData, _guest.Cart.GetCartStorage());
         MarketLog.Log("UserSpot", "User " + loggedUser.SystemID + " sign in to the system has been successfull!");
         MarketLog.Log("UserSpot", "User " + loggedUser.SystemID + " is now recognized as Registered User "
                       + loggedUser.SystemID);
         string returnedState = loggedUser.IsSystemAdmin() ? "Admin" : "Registered";
         Answer = new UserAnswer(SignInStatus.Success, "Sign in has been successful!", loggedUser.SystemID, returnedState);
         return(loggedUser);
     }
     catch (UserException e)
     {
         MarketLog.Log("UserSpot",
                       "User " + guestID + " has failed to sign in. Error message has been created!");
         Answer = new UserAnswer((SignInStatus)e.Status, e.GetErrorMessage());
         return(_guest);
     }
     catch (DataException e)
     {
         Answer = new UserAnswer((SignInStatus)e.Status, e.GetErrorMessage());
         return(_guest);
     }
 }