Esempio n. 1
0
        private static void LoadDataIntoSession(System.Web.SessionState.HttpSessionState session)
        {
            Repositories.UserRepository userRepo = new Repositories.UserRepository();

            Domain.User loggedUser = userRepo.GetUserDetails(HttpContext.Current.User.Identity.Name);
            if (loggedUser != null)
            {
                loggedUser.Roles.AddRange(userRepo.GetRolesAsArray(loggedUser.Username));

                session[Constants.USER] = loggedUser;
            }
        }
Esempio n. 2
0
        private static void LoadDataIntoSession(System.Web.HttpSessionStateBase session, string userName)
        {
            Repositories.UserRepository userRepo = new Repositories.UserRepository();

            Domain.User loggedUser = userRepo.GetUserDetails(userName);

            if (loggedUser != null)
            {
                loggedUser.Roles.AddRange(userRepo.GetRolesAsArray(loggedUser.Username));

                session[USER] = loggedUser;
            }
        }
        protected void lbtnCompleteRegStep2_clicked(object sender, System.EventArgs e)
        {
            try
            {
                #region Commented Out update invitee

                string redirectUrl = string.Empty;
                string username    = this.txtEmail2.Text;
                string password    = this.txtPass2.Text;

                Invitee updatedInvitee = new Invitee();
                updatedInvitee.Email     = username;
                updatedInvitee.FirstName = this.txtFirstName2.Text;
                updatedInvitee.LastName  = this.txtLastName2.Text;
                updatedInvitee.Clinic    = this.txtClinicName.Text;
                updatedInvitee.Address   = this.txtAddress.Text;
                updatedInvitee.City      = this.txtCity2.Text;
                updatedInvitee.Province  = new Province()
                {
                    ID = Int32.Parse(ddProvince2.SelectedValue)
                };
                updatedInvitee.PostalCode = this.txtPostalCode.Text;
                updatedInvitee.Phone      = this.txtPhone.Text;
                //this.txtCell.Text = invitee.Cell;
                updatedInvitee.Fax = this.txtFax.Text;
                updatedInvitee.RegistrationCode = regCode;
                updatedInvitee.CellPhone        = this.txtCell.Text;

                this.invRepos.UpdateInviteeDataAndRegister(updatedInvitee, username, password);

                //SendEmail(updatedInvitee.Email); //send email to physician

                try
                {
                    //SendEmail(
                    //         ConfigurationSettings.AppSettings[Helper.Constants.EMAILGENERAL].ToString(),
                    //        updatedInvitee.LastName,
                    //        username,
                    //        password
                    // );


                    SendEmail(
                        updatedInvitee.Email,
                        updatedInvitee.LastName,
                        username,
                        password
                        );

                    SendEmailToCHRC(
                        updatedInvitee.FirstName,
                        updatedInvitee.LastName,
                        username,
                        ConfigurationSettings.AppSettings[Helper.Constants.NOTIFIEDOFREGISTRANT].ToString()
                        );

                    //throw new Exception("Email Exception");
                }
                catch (Exception exc)
                {
                    Elmah.ErrorSignal.FromCurrentContext().Raise(exc);
                }

                #endregion

                #region Loggin in

                UserRepository userRepo = new Repositories.UserRepository();

                if (userRepo.AutheticateUser(username, password))
                {
                    string[] userRoles = userRepo.GetRolesAsArray(username);

                    HttpCookie AuthorizationCookie = UserHelper.GetAuthorizationCookie(username, userRepo.GetRoles(username));

                    HttpContext.Current.User = new GenericPrincipal(User.Identity, userRoles);

                    Response.Cookies.Add(AuthorizationCookie);


                    Domain.User loggedUser = userRepo.GetUserDetails(username);

                    loggedUser.Roles.AddRange(userRoles);

                    UserHelper.SetLoggedInUser(loggedUser, HttpContext.Current.Session);


                    if (HttpContext.Current.User.IsInRole(Helper.Constants.ADMIN_ROLE))
                    {
                        redirectUrl = "~/Admin/ManageRegistration.aspx";
                    }
                    else
                    if (HttpContext.Current.User.IsInRole(Helper.Constants.VALIENT_ROLE))
                    {
                        redirectUrl = "~/Admin/SelectProvince.aspx";
                    }
                    else
                    {
                        redirectUrl = FormsAuthentication.GetRedirectUrl(username, true);
                    }


                    Response.Redirect(redirectUrl, false);
                }

                #endregion

                // regView.ActiveViewIndex = 2;
            }
            catch (Exception exc)
            {
                lblMssg.Text = exc.InnerException.Message;
            }
        }