/// <summary> /// Update User /// </summary> /// <param name="firstName"></param> /// <param name="lastName"></param> /// <param name="userName"></param> /// <param name="emailAddress"></param> /// <param name="password"></param> /// <param name="passwordConfirmation"></param> /// <param name="transaction"></param> /// <returns></returns> public taccount UpdateUser(int userID, string firstName, string lastName, string userName, string emailAddress, string password, string passwordConfirmation, out TransactionalInformation transaction) { transaction = new TransactionalInformation(); AdminBusinessRules accountsBusinessRules = new AdminBusinessRules(); taccount user = new taccount(); try { accountsDataService.CreateSession(); user = accountsDataService.GetUser(userID); //user.FirstName = firstName.Trim(); //user.LastName = lastName.Trim(); //user.EmailAddress = emailAddress.Trim(); //user.Password = password.Trim(); //user.UserName = userName.Trim(); accountsBusinessRules.ValidateExistingUser(user, accountsDataService); accountsBusinessRules.ValidatePassword(password, passwordConfirmation); if (accountsBusinessRules.ValidationStatus == true) { accountsDataService.BeginTransaction(); //accountsDataService.UpdateUser(user); accountsDataService.CommitTransaction(true); transaction.ReturnStatus = true; } else { transaction.ReturnStatus = accountsBusinessRules.ValidationStatus; transaction.ReturnMessage = accountsBusinessRules.ValidationMessage; transaction.ValidationErrors = accountsBusinessRules.ValidationErrors; } } catch (Exception ex) { transaction.ReturnMessage = new List <string>(); string errorMessage = ex.Message; transaction.ReturnStatus = false; transaction.ReturnMessage.Add(errorMessage); } finally { accountsDataService.CloseSession(); } return(user); }
/// <summary> /// Register User /// </summary> /// <param name="firstName"></param> /// <param name="lastName"></param> /// <param name="userName"></param> /// <param name="emailAddress"></param> /// <param name="password"></param> /// <param name="passwordConfirmation"></param> /// <param name="transaction"></param> /// <returns></returns> public taccount RegisterUser(string firstName, string lastName, string userName, string emailAddress, string password, string passwordConfirmation, out TransactionalInformation transaction) { transaction = new TransactionalInformation(); AdminBusinessRules accountsBusinessRules = new AdminBusinessRules(); taccount user = new taccount(); try { //user.FirstName = Utilities.UppercaseFirstLetter(firstName.Trim()); //user.LastName = Utilities.UppercaseFirstLetter(lastName.Trim()); //user.EmailAddress = emailAddress.Trim(); //user.Password = password.Trim(); //user.UserName = userName.Trim(); accountsDataService.CreateSession(); accountsBusinessRules.ValidateUser(user, accountsDataService); accountsBusinessRules.ValidatePassword(password, passwordConfirmation); if (accountsBusinessRules.ValidationStatus == true) { accountsDataService.BeginTransaction(); //accountsDataService.RegisterUser(user); accountsDataService.CommitTransaction(true); transaction.ReturnStatus = true; transaction.ReturnMessage.Add("User registered successfully."); } else { transaction.ReturnStatus = accountsBusinessRules.ValidationStatus; transaction.ReturnMessage = accountsBusinessRules.ValidationMessage; transaction.ValidationErrors = accountsBusinessRules.ValidationErrors; } } catch (Exception ex) { transaction.ReturnMessage = new List <string>(); string errorMessage = ex.Message; transaction.ReturnStatus = false; transaction.ReturnMessage.Add(errorMessage); } finally { accountsDataService.CloseSession(); } return(user); }