Beispiel #1
0
 protected void RegisterButton_Click(object sender, EventArgs e)
 {
     UserDetails NewUser = new UserDetails();
     UserRegistrationClient ClientCompany = new UserRegistrationClient();
     Company[] Companynames = ClientCompany.RetriveCompanyNames();
     string companyName = CompanyID.Text;
     int i = 0;
     for (i = 0; i < Companynames.Length; i++)
     {
         int res = string.Compare(Companynames[i].Name, companyName, true);
         if (res == 0)
         {
             NewUser.CompanyId = Companynames[i].CompanyID;
             break;
         }
     }
     if (i == Companynames.Length)
     {
         ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "err_msg", "alert('Enter correct company name or Register your Company.');", true);
         return;
     }
     NewUser.FirstName = FirstName.Text;
     NewUser.LastName = LastName.Text;
     NewUser.UserEmail = Email.Text;
     NewUser.EncryptedPassword = Password.Text;
     NewUser.IsOwner = false;
     UserRegistrationClient client = new UserRegistrationClient();
     bool success = client.UserRegistration(NewUser);
     if (success)
         ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "err_msg", "alert('You are registered');window.location='Login.aspx'", true);
     else
         ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "err_msg", "alert('error');", true);
     return;
 }
        protected void RegisterButton_Click(object sender, EventArgs e)
        {
            UserDetails NewUser    = new UserDetails();
            Company     newcompany = new Company();

            newcompany.Name    = CompanyName.Text;
            newcompany.Account = txtCompanyAccount.Text;
            newcompany.Url     = txtCompanyURL.Text;
            UserRegistrationClient client = new UserRegistrationClient();

            NewUser.CompanyId         = client.CompanyRegistration(newcompany);
            NewUser.FirstName         = FirstName.Text;
            NewUser.LastName          = LastName.Text;
            NewUser.UserEmail         = Email.Text;
            NewUser.EncryptedPassword = Password.Text;
            NewUser.IsOwner           = true;
            bool success = client.UserRegistration(NewUser);

            if (success)
            {
                ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "err_msg", "alert('You and your Company are registered');", true);
            }
            else
            {
                ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "err_msg", "alert('error');", true);
            }
            Response.Redirect("Login.aspx");
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            UserRegistrationClient ClientCompany = new UserRegistrationClient();

            Company[] Companynames = ClientCompany.RetriveCompanyNames();
            for (int i = 0; i < Companynames.Length; i++)
            {
                CompanyID.Items.Add(new ListItem(Companynames[i].Name, Companynames[i].CompanyID.ToString()));
            }
        }
Beispiel #4
0
        public ActionResult UserRegister(UserRegisterViewModel registerUser)
        {
            string errorMessage = null;

            if (registerUser == null)
            {
                registerUser = new UserRegisterViewModel();
                errorMessage = MessageManager.GetMessage(OperationStatus.DataFormatError);
            }
            else
            {
                try
                {
                    IAccountDriver         driver = DependencyResolver.Current.GetService <IAccountDriver>();
                    TokenUser              tokenUser;
                    UserRegistrationClient client = new UserRegistrationClient()
                    {
                        UserName      = registerUser.UserName,
                        RegisterEmail = registerUser.RegisterEmail,
                        Password      = registerUser.Password
                    };
                    OperationStatus status = driver.TryRegister(client, out tokenUser);
                    if (status == OperationStatus.RegisterSuccess)
                    {
                        SaveTicketToCookie(tokenUser, false);
                        string returnUrl = FormsAuthentication.GetRedirectUrl(string.Empty, false);
                        return(Redirect(returnUrl));
                    }
                    else
                    {
                        errorMessage = MessageManager.GetMessage(status);
                    }
                }
                catch
                {
                    errorMessage = MessageManager.GetMessage(OperationStatus.GenericError);
                }
            }

            if (!string.IsNullOrEmpty(errorMessage))
            {
                ViewBag.ErrorMessage = errorMessage;
            }
            return(PartialView("_UserRegister", registerUser));
        }
        protected void RegisterButton_Click(object sender, EventArgs e)
        {
            UserDetails            NewUser       = new UserDetails();
            UserRegistrationClient ClientCompany = new UserRegistrationClient();

            Company[] Companynames = ClientCompany.RetriveCompanyNames();
            string    companyName  = CompanyID.Text;
            int       i            = 0;

            for (i = 0; i < Companynames.Length; i++)
            {
                int res = string.Compare(Companynames[i].Name, companyName, true);
                if (res == 0)
                {
                    NewUser.CompanyId = Companynames[i].CompanyID;
                    break;
                }
            }
            if (i == Companynames.Length)
            {
                ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "err_msg", "alert('Enter correct company name or Register your Company.');", true);
                return;
            }
            NewUser.FirstName         = FirstName.Text;
            NewUser.LastName          = LastName.Text;
            NewUser.UserEmail         = Email.Text;
            NewUser.EncryptedPassword = Password.Text;
            NewUser.IsOwner           = false;
            UserRegistrationClient client = new UserRegistrationClient();
            bool success = client.UserRegistration(NewUser);

            if (success)
            {
                ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "err_msg", "alert('You are registered');window.location='Login.aspx'", true);
            }
            else
            {
                ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "err_msg", "alert('error');", true);
            }
            return;
        }
Beispiel #6
0
        public ClientJsonResult Register(UserRegistrationClient registerUser)
        {
            if (registerUser != null)
            {
                try
                {
                    registerUser.ClearNotifications();
                    IAccountDriver  driver = DependencyResolver.Current.GetService <IAccountDriver>();
                    TokenUser       tokenUser;
                    OperationStatus status = driver.TryRegister(registerUser, out tokenUser);
                    if (status == OperationStatus.RegisterSuccess)
                    {
                        SaveTicketToCookie(tokenUser, false);
                        TokenUserClient clientTokenUser = new TokenUserClient(tokenUser);
                        clientTokenUser.AddSuccessNotification(MessageManager.GetMessage(status));
                        return(ClientJson(clientTokenUser));
                    }
                    else
                    {
                        registerUser.ServerStatus = false;
                        registerUser.AddErrorNotification(MessageManager.GetMessage(status));
                    }
                }
                catch (Exception ex)
                {
                    registerUser.ServerStatus = false;
                    LoggingWork.Error(ex);
                    registerUser.AddErrorNotification(MessageManager.GetMessage(OperationStatus.GenericError));
                }
            }
            else
            {
                registerUser = new UserRegistrationClient()
                {
                    ServerStatus = false
                };
                registerUser.AddErrorNotification(MessageManager.GetMessage(OperationStatus.DataFormatError));
            }

            return(ClientJson(registerUser));
        }
        public OperationStatus TryRegister(UserRegistrationClient registerUser, out TokenUser tokenUser)
        {
            if (registerUser == null)
            {
                tokenUser = null; return(OperationStatus.DataFormatError);
            }

            tokenUser = null;
            registerUser.ServerStatus = false;
            OperationStatus status = OperationStatus.None;

            try
            {
                var circleUser = _userWork.Create();
                circleUser.UserName      = registerUser.UserName;
                circleUser.RegisterEmail = registerUser.RegisterEmail;
                circleUser.Password      = registerUser.Password;
                status = _userWork.Save(circleUser);

                if (status == OperationStatus.Success)
                {
                    MemberRole role = _roleWork.AllCacheItems.Where(x => x.Id == circleUser.RoleId).SingleOrDefault();
                    tokenUser = new TokenUser(circleUser, role);
                    SecurityManager.AddOrUpdateCurrentTokenUser(tokenUser);
                    status = OperationStatus.RegisterSuccess;
                    registerUser.ServerStatus = true;
                    return(status);
                }
            }
            catch (Exception ex)
            {
                tokenUser = null;
                status    = OperationStatus.GenericError;
                registerUser.ServerStatus = false;
                LoggingWork.Error(ex);
            }


            tokenUser = null;
            return(status);
        }
 protected void RegisterButton_Click(object sender, EventArgs e)
 {
     UserDetails NewUser = new UserDetails();
        Company newcompany = new Company();
        newcompany.Name = CompanyName.Text;
        newcompany.Account = txtCompanyAccount.Text;
        newcompany.Url = txtCompanyURL.Text;
        UserRegistrationClient client = new UserRegistrationClient();
        NewUser.CompanyId = client.CompanyRegistration(newcompany);
        NewUser.FirstName = FirstName.Text;
        NewUser.LastName= LastName.Text;
        NewUser.UserEmail = Email.Text;
        NewUser.EncryptedPassword = Password.Text;
        NewUser.IsOwner = true;
        bool success = client.UserRegistration(NewUser);
        if(success)
        ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "err_msg", "alert('Welcome to Roadmunk!!!');", true);
        else
        ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "err_msg", "alert('error');", true);
     Response.Redirect("Login.aspx");
 }
        protected void RegisterButton_Click(object sender, EventArgs e)
        {
            UserDetails NewUser = new UserDetails();

            NewUser.CompanyId         = Convert.ToInt32(CompanyID.SelectedValue);
            NewUser.FirstName         = FirstName.Text;
            NewUser.LastName          = LastName.Text;
            NewUser.UserEmail         = Email.Text;
            NewUser.EncryptedPassword = Password.Text;
            NewUser.IsOwner           = false;
            UserRegistrationClient client = new UserRegistrationClient();
            bool success = client.UserRegistration(NewUser);

            if (success)
            {
                ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "err_msg", "alert('You are registered');", true);
            }
            else
            {
                ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "err_msg", "alert('error');", true);
            }
            Response.Redirect("Login.aspx");
        }