Пример #1
0
        public RegistrationPresenter(IRegistrationView registrationView, IRegistrationService registrationService)
        {
            this.registrationView    = registrationView;
            this.registrationService = registrationService;

            SubscribeToEvents();
        }
Пример #2
0
 public RegistrationViewModel(IRegistrationView view)
 {
     Museum    = new RegisterData();
     this.View = view;
     this.View.BindDataContext(this);
     this.accountService = AppData.Container.Resolve <IAccountService>();
 }
Пример #3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="registrationInfo"></param>
        /// <param name="registrationId"></param>
        /// <returns></returns>
        public IEmailDetail CreateRegistrationRequestEmail(IRegistrationView registrationInfo, int registrationId, string activationCode)
        {
            if (registrationInfo == null)
            {
                throw new ArgumentNullException(nameof(registrationInfo));
            }

            var theSubject = "Welcome to AA HRMS";
            var recipient  = registrationInfo.Email;
            var theBody    = "Your registration was successful, we look forward to facilitate the growth and management of your Company.";

            theBody = string.Format("{0} {1}", theBody, "<br><br> Your username is your email or username");
            theBody = string.Format("{0} {1}", theBody, "<br><br>Please click the link below to activate you account ");
            theBody = string.Format("{0} {1} {2} {3}", theBody, "<br><br> <a class='btn sm-btn' href='localhost:5200/Account/Activate?activationCode=", activationCode, "'>Click Here</a>");
            theBody = string.Format("{0} {1}", theBody, "<br><br> Thank you");

            var mailDetail = new EmailDetail
            {
                Body       = theBody,
                Recipients = recipient,
                Subject    = theSubject
            };

            return(mailDetail);
        }
Пример #4
0
        public RegistrationPresenter(IRegistrationView view, IRegistrationValidatorProvider provider, IRepositoryProvider <User> repositoryProvider)
        {
            this.provider           = provider;
            this.view               = view;
            this.repositoryProvider = repositoryProvider;

            SubscribeToViewEvents();
            SetUpView();
        }
Пример #5
0
        public void DeleteUser(IRegistrationView registrationView, IUserRepository userRepository, IRecordRepository recordRepository, ICurrentUserRepository currUsrRepo)
        {
            string currentUserUsername = currUsrRepo.getUsername();
            User   user = userRepository.findUserByID(currentUserUsername);

            recordRepository.deleteUserRecords(currentUserUsername);
            userRepository.DeleteUser(user);
            registrationView.ShowViewModal();
        }
Пример #6
0
 public RegistrationPresenter(IKernel kernel, IRegistrationView view, IRegistrationService service)
 {
     this.kernel  = kernel;
     this.view    = view;
     this.service = service;
     this.view.Show();
     this.view.PushRegistration      += PushRegistration;
     this.service.UserCantBeRegister += WrongRegisterData;
 }
Пример #7
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="registrationInfo"></param>
        /// <param name="registrationId"></param>
        /// <returns></returns>
        public IEmailDetail CreateRegistrationConfirmationEmail(IRegistrationView registrationInfo, int registrationId)
        {
            var mailDetail = new EmailDetail
            {
                Body       = "Your registration is confirmed",
                Recipients = registrationInfo.Email,
                Subject    = "Stop bordering us"
            };

            return(mailDetail);
        }
Пример #8
0
        /// <summary>
        /// Creates the authentication page.
        /// </summary>
        /// <param name="registrationView">The registration view.</param>
        /// <param name="logOnView">The log on view.</param>
        /// <param name="changePasswordView">The change password view.</param>
        /// <returns></returns>
        public IHomeView CreateAuthenticationPage(IRegistrationView registrationView, ILogOnView logOnView, IChangePasswordView changePasswordView, string processingMessage)
        {
            var model = new HomeModelView
            {
                Registration      = registrationView,
                LogOn             = logOnView,
                ChangePassword    = changePasswordView,
                ProcessingMessage = processingMessage,
            };

            return(model);
        }
Пример #9
0
        /// <summary>
        /// Gets the registration view.
        /// </summary>
        /// <param name="registrationData">The registration data.</param>
        /// <returns></returns>
        public IRegistrationView GetRegistrationView(IRegistrationView registrationData)
        {
            // about us source records from database
            var aboutUsSourceCollection = this.lookupRepository.GetAboutUsSourceCollection().ToList();

            // send it to accounts view factory to create the view factory
            var viewModel =
                this.accountViewsModelFactory.CreateUpdatedRegistraionView(registrationData, "",
                                                                           aboutUsSourceCollection);

            // return the view to controller
            return(viewModel);
        }
Пример #10
0
        private void CreateAndSubscribeToRegistrationWindow()
        {
            registrationView = UICreator
                               .GetInstance()
                               .Create <RegistrationWindow>();

            if (registrationView != null)
            {
                registrationView.RegisterButtonClicked +=
                    OnRegisterButtonClicked;
                registrationView.BackButtonClicked +=
                    OnBackButtonClicked;
            }
        }
Пример #11
0
        /// <summary>
        /// Saves the registration information.
        /// </summary>
        /// <param name="registrationInfo">The registration information.</param>
        /// <param name="registrationId">The registration identifier.</param>
        /// <returns></returns>
        /// <exception cref="ArgumentNullException">registrationInfo</exception>
        public string SaveRegistrationInfo(IRegistrationView registrationInfo, out int registrationId)
        {
            if (registrationInfo == null)
            {
                throw new ArgumentNullException(nameof(registrationInfo));
            }

            var result    = string.Empty;
            var newRecord = new Registration
            {
                Username        = registrationInfo.Username,
                Password        = registrationInfo.Password,
                CompanyId       = 0,
                FirstName       = registrationInfo.FirstName,
                Lastname        = registrationInfo.LastName,
                CompanyName     = registrationInfo.CompanyName,
                Email           = registrationInfo.Email,
                PhoneNumber     = registrationInfo.PhoneNumber,
                AboutUsSourceId = registrationInfo.AboutUsSourceId,
                AboutUsOthers   = registrationInfo.AboutUsOthers,
                IsActive        = registrationInfo.IsActive,
                IsRegistered    = false,
                DateCreated     = DateTime.Now
            };

            try
            {
                using (
                    var dbContext = (HRMSEntities)this.dbContextFactory.GetDbContext(ObjectContextType.HRMS))
                {
                    dbContext.Registrations.Add(newRecord);
                    dbContext.SaveChanges();
                }
            }
            catch (Exception e)
            {
                result = string.Format("SaveRegistrationInfo - {0} , {1}", e.Message,
                                       e.InnerException != null ? e.InnerException.Message : "");
            }

            registrationId = newRecord.RegistrationId;
            return(result);

            ;
        }
Пример #12
0
        /// <summary>
        /// Creates the user role.
        /// </summary>
        /// <param name="registrationInfo">The registration information.</param>
        /// <returns></returns>
        /// <exception cref="ArgumentNullException">registrationInfo</exception>
        public string CreateUserRole(IRegistrationView registrationInfo)
        {
            if (registrationInfo == null)
            {
                throw new ArgumentNullException(nameof(registrationInfo));
            }

            var result    = string.Empty;
            var newRecord = new UserAppRole
            {
                Username         = registrationInfo.Username,
                DateCreated      = DateTime.Now,
                CreateByUsername = registrationInfo.Username
            };

            if (registrationInfo.SelectedRole == "CompanyAdmin")
            {
                newRecord.AppRoleId = 5; //CompanyAdmin
            }

            if (registrationInfo.SelectedRole == "Employee")
            {
                newRecord.AppRoleId = 2; //Employee
            }

            try
            {
                using (
                    var dbContext = (HRMSEntities)this.dbContextFactory.GetDbContext(ObjectContextType.HRMS))
                {
                    dbContext.UserAppRoles.Add(newRecord);
                    dbContext.SaveChanges();
                }
            }
            catch (Exception e)
            {
                result = string.Format("CreateUserRole - {0} , {1}", e.Message,
                                       e.InnerException != null ? e.InnerException.Message : "");
            }


            return(result);
        }
Пример #13
0
        /// <summary>
        /// Creates the updated registraion view.
        /// </summary>
        /// <param name="registrationInfo">The registration information.</param>
        /// <param name="processingMessage">The processing message.</param>
        /// <param name="aboutUsSourceCollection">The about us source collection.</param>
        /// <returns></returns>
        /// <exception cref="ArgumentNullException">
        /// registrationInfo
        /// or
        /// aboutUsSourceCollection
        /// </exception>
        public IRegistrationView CreateUpdatedRegistraionView(IRegistrationView registrationInfo,
                                                              string processingMessage, IList <IHowSource> aboutUsSourceCollection)
        {
            if (registrationInfo == null)
            {
                throw new ArgumentNullException(nameof(registrationInfo));
            }

            if (aboutUsSourceCollection == null)
            {
                throw new ArgumentNullException(nameof(aboutUsSourceCollection));
            }

            var aboutUsSourceDDL =
                GetDropDownList.AboutUsSourceListItems(aboutUsSourceCollection, registrationInfo.AboutUsSourceId);

            registrationInfo.AboutUsSourceDropDown = aboutUsSourceDDL;

            return(registrationInfo);
        }
Пример #14
0
        public RegistrationPresenter(IRegistrationView iRegistrationView, IRegistrationModel iRegistrationModel, IMedicalCardManager iMedicalCardManager)
        {
            if (iRegistrationView is null)
            {
                throw new ArgumentNullException(String.Format("{0} is null", nameof(iRegistrationView)));
            }

            if (iRegistrationModel is null)
            {
                throw new ArgumentNullException(String.Format("{0} is null", nameof(iRegistrationModel)));
            }

            if (iMedicalCardManager is null)
            {
                throw new ArgumentNullException(String.Format("{0} is null", nameof(iMedicalCardManager)));
            }

            this.iRegistrationView   = iRegistrationView;
            this.iRegistrationModel  = iRegistrationModel;
            this.iMedicalCardManager = iMedicalCardManager;

            iRegistrationView.RegistrationFormLoad += IRegistrationView_RegistrationFormLoad;
            iRegistrationView.SaveChanges          += IRegistrationView_SaveChanges;
        }
 public RegisterPresenter(IRegistrationView registerWindow)
 {
     model = new EnterRegisterModel();
     win   = registerWindow;
     win.RegisterButton_Click += new EventHandler(registerWindow_RegisterButtonClick);
 }
Пример #16
0
 public void GoToRegistration(IRegistrationView RegistrationView)
 {
     RegistrationView.ShowViewModal();
 }
        public RegistrationPresenter(IRegistrationView view)
        {
            this.view = view;

            Initialize();
        }
Пример #18
0
 public void SetFramesContent(ILoginView login, IRegistrationView register)
 {
     this.AddReg.Content = register;
     this.Main.Content   = login;
 }
Пример #19
0
        /// <summary>
        /// Processes the registration information.
        /// </summary>
        /// <param name="registrationInfo">The registration information.</param>
        /// <returns></returns>
        /// <exception cref="System.ArgumentNullException">registrationInfo</exception>
        public IRegistrationView ProcessRegistrationInfo(IRegistrationView registrationInfo)
        {
            if (registrationInfo == null)
            {
                throw new System.ArgumentNullException(nameof(registrationInfo));
            }

            var processingMessage = string.Empty;
            var isDataOkay        = true;

            // validate entries
            // 1) check userId does not exist in RegisterTable
            var registrationData = this.accountRepository.GetRegistrationByUsername(registrationInfo.Username);
            var isRecordExist    = (registrationData == null) ? false : true;

            if (isRecordExist)
            {
                processingMessage = Messages.UserAlreadyExistText;
                isDataOkay        = false;
            }

            // 2) check that email not used if no error so far
            if (isDataOkay)
            {
                registrationData = this.accountRepository.GetRegistrationByEmail(registrationInfo.Email);
                isRecordExist    = (registrationData == null) ? false : true; // checks if registration already exist
                isDataOkay       =
                    isRecordExist
                        ? false
                        : true; // implies registration info already exists and registration can not go through


                // set processing message
                if (isRecordExist)
                {
                    processingMessage =
                        isRecordExist ? Messages.EmailAlreadyUsedText : ""; // email already used for registration

                    if (registrationData.IsRegistered)
                    {
                        processingMessage = (isRecordExist && registrationData.IsRegistered)
                            ? Messages.ConfirmRegistrationText
                            : ""; // email used and registration not confirmed by user
                    }
                }
            }

            // get updated view model to be returned to controller
            var aboutUsSourceCollection = this.lookupRepository.GetAboutUsSourceCollection().ToList();
            var returnViewModel         =
                this.accountViewsModelFactory.CreateUpdatedRegistraionView(registrationInfo, processingMessage,
                                                                           aboutUsSourceCollection);

            if (!isDataOkay)
            {
                returnViewModel.ProcessingMessage = processingMessage;
                return(returnViewModel);
            }

            //save data to database
            var userId = 0;

            // encrypt password here
            registrationInfo.Password = this.encryptionService.Encrypt(registrationInfo.Password);

            var IsEmployee = this.employeeOnBoardRepository.GetEmployeeByEmail(registrationInfo.Email) == null ? false: true;

            if (registrationInfo.SelectedRole == "Employee" && IsEmployee == false)
            {
                processingMessage = Messages.NoEmployeeRecord;

                returnViewModel.ProcessingMessage = processingMessage;

                return(returnViewModel);
            }

            if (IsEmployee && registrationInfo.SelectedRole == "Employee")
            {
                var employee = this.employeeOnBoardRepository.GetEmployeeByEmail(registrationInfo.Email);
                registrationInfo.FirstName     = employee.FirstName;
                registrationInfo.LastName      = employee.LastName;
                registrationInfo.PhoneNumber   = employee.MobileNumber;
                registrationInfo.AboutUsOthers = "Bought by my company";
                registrationInfo.CompanyId     = employee.CompanyId;
            }


            var savedData = this.accountRepository.SaveUserInfo(registrationInfo, out userId);

            //: Create User App Role
            this.accountRepository.CreateUserRole(registrationInfo);


            //Generate Activation Code
            string activationCode =
                String.Format("{0}{1}", userId, this.usersRepository.CreateActivationCode());

            this.accountRepository.StoreActivationCode(userId, activationCode);

            // generate email details
            var registrationRequestEmail =
                emailFactory.CreateRegistrationRequestEmail(registrationInfo, userId, activationCode);

            var emailKey = this.environment[EnvironmentValues.EmailKey];

            // send email to user including token or unique id for registration confirmation
            this.email.Send(emailKey, "aahrms.automataapps.com", "AA HRMS Team", registrationRequestEmail.Subject, registrationRequestEmail.Recipients, registrationInfo.LastName + " " + registrationInfo.FirstName, string.Empty, registrationRequestEmail.Body);

            return(returnViewModel);
        }
Пример #20
0
 public RegistrationPresenter(IRegistrationView registrationPresenter)
 {
     _registrationView = registrationPresenter;
     userService       = new UserService();
 }
Пример #21
0
 public RegistrationPresenter(IRegistrationView view)
 {
     _view = view;
 }