Beispiel #1
0
        /// <summary>
        /// UserAlreadyExist
        /// </summary>
        /// <param name="strEmailAddress"></param>
        /// <param name="password"></param>
        /// <returns></returns>
        public UsersModel ResetEncodeStringExist(string strEncodeString)
        {
            UsersBAL objUser = new UsersBAL();

            try
            {
                UsersModel objUsersModel = objUser.ResetEncodeStringExist(strEncodeString);
                if (objUsersModel != null)
                {
                    return(objUsersModel);
                }
                else
                {
                    return(null);
                }
            }
            catch
            {
                return(null);
            }
            finally
            {
                objUser = null;
            }
        }
Beispiel #2
0
 public int UpdateUsers(UsersBAL ub)
 {
     try
     {
         using (C.Con)
         {
             MySqlCommand cmd = new MySqlCommand("UpdateUsers", C.Con)
             {
                 CommandType = CommandType.StoredProcedure
             };
             cmd.Parameters.Add(new MySqlParameter("U_ID", ub.UserID));
             cmd.Parameters.Add(new MySqlParameter("UName", ub.Username));
             cmd.Parameters.Add(new MySqlParameter("PWord", ub.Password));
             cmd.Connection.Open();
             int Result = cmd.ExecuteNonQuery();
             C.Con.Close();
             return(Result);
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
         throw;
     }
 }
Beispiel #3
0
        /// <summary>
        /// UserAlreadyExist
        /// </summary>
        /// <param name="strEmailAddress"></param>
        /// <param name="password"></param>
        /// <returns></returns>
        public int UserAlreadyExist(string strEmailAddress)
        {
            UsersBAL objUser = new UsersBAL();

            try
            {
                List <UsersModel> lstUsersModel = objUser.GetPasswordByEmail(strEmailAddress);
                if (lstUsersModel != null && lstUsersModel.Count > 0)
                {
                    return(1);
                }
                else
                {
                    return(0);
                }
            }
            catch
            {
                return(2);
            }
            finally
            {
                objUser = null;
            }
        }
Beispiel #4
0
        /// <summary>
        /// UserAlreadyExist
        /// </summary>
        /// <param name="strEmailAddress"></param>
        /// <param name="password"></param>
        /// <returns></returns>
        public int ConfirmeRegistration(string strEncodeString)
        {
            UsersBAL objUser = new UsersBAL();

            try
            {
                List <UsersModel> lstUsersModel = objUser.GetConfirmeRegistration(strEncodeString);
                if (lstUsersModel != null && lstUsersModel.Count > 0)
                {
                    UpdateUserStatus(lstUsersModel[0].ID, "confirm", "");
                    Session["LoginEmailAddress"]    = lstUsersModel[0].EmailAddress;
                    Session["LoginCurrentPassword"] = lstUsersModel[0].Password;
                    return(1);
                }
                else
                {
                    return(0);
                }
            }
            catch
            {
                return(2);
            }
            finally
            {
                objUser = null;
            }
        }
Beispiel #5
0
        public ActionResult ChangePassword(FormCollection formCollection)
        {
            string emailAddress = "";

            if (Session["LoginEmailAddress"] != null)
            {
                emailAddress = Convert.ToString(Session["LoginEmailAddress"]);
            }
            else
            {
                return(RedirectToAction("Index", "User"));
            }

            UsersBAL objUserBAL = new UsersBAL();

            logger.Debug("Change Password");
            string currentpassword = "", password = "", confirmPassword = "";

            foreach (string key in formCollection.Keys)
            {
                if (key == "currentpassword")
                {
                    currentpassword = formCollection[key].Trim();
                }
                else if (key == "password")
                {
                    password = formCollection[key].Trim();
                }
                else if (key == "confirmpassword")
                {
                    confirmPassword = formCollection[key].Trim();
                }
            }

            logger.Debug("Validations check");
            if (string.IsNullOrEmpty(currentpassword) || string.IsNullOrEmpty(password) || string.IsNullOrEmpty(confirmPassword) || string.IsNullOrEmpty(emailAddress))
            {
                return(RedirectToAction("Message", "MessageDisplay", new { E = 41 }));
            }
            if (password.Length < 6)
            {
                return(RedirectToAction("Message", "MessageDisplay", new { E = 46 }));
            }
            if (password != confirmPassword)
            {
                return(RedirectToAction("Message", "MessageDisplay", new { E = 36 }));
            }

            logger.Debug("Call Change password Method");
            int retVal = ChangePasswordMethod(emailAddress, currentpassword, password);

            if (retVal == 1)
            {
                return(RedirectToAction("Message", "MessageDisplay", new { E = 45 }));
            }
            else
            {
                return(RedirectToAction("Message", "MessageDisplay", new { E = 47 }));
            }
        }
Beispiel #6
0
        /// <summary>
        /// RegisterNewUser
        /// </summary>
        /// <param name="strEmailAddress"></param>
        /// <param name="password"></param>
        /// <returns></returns>
        public int RegisterNewUser(string strEmailAddress, string password, string encodestring)
        {
            UsersBAL objUser = new UsersBAL();

            try
            {
                UsersModel objUsersModel = new UsersModel();
                objUsersModel.EmailAddress = strEmailAddress;
                objUsersModel.Password     = password;
                objUsersModel.ID           = 0;
                objUsersModel.Status       = "pending";
                objUsersModel.encodestring = encodestring;
                int intNewUserRegistered = objUser.RegisterNewUSer(objUsersModel);
                //Send E-mail
                //SendEmail(Common.MailType.ConfirmRegistration, strEmailAddress);

                emailModel        objEmailmodel = new emailModel();
                emailBAL          objEmailBAL   = new emailBAL();
                List <emailModel> lstemailmodel = objEmailBAL.FindEmail("MyTP-Confirm-Register-JAPA");

                if (lstemailmodel.Count > 0)
                {
                    DataTable DT = Common.ListToDataTable(lstemailmodel);
                    if (DT != null)
                    {
                        DataRow DR       = DT.Rows[0];
                        string  FileName = ConfigurationManager.AppSettings["EmailTemplatePath"] + Convert.ToString(DR["html_xslt_file"]);

                        //string buffer = Common.ReadFileFromDisk(FileName, ref logger);

                        XmlDocument xd = new XmlDocument();

                        xd.LoadXml("<tbdoc><encodestring>" + Server.UrlEncode(encodestring) + "</encodestring></tbdoc>");

                        string body = RunXSLTransform(FileName, xd).ToHtmlString();

                        string FromAddress = Convert.ToString(DR["from_address"]);
                        string FromName    = Convert.ToString(DR["from_name"]);
                        string subject     = Convert.ToString(DR["subject"]);
                        string cc          = Convert.ToString(DR["cc"]);
                        string bcc         = Convert.ToString(DR["bcc"]);

                        Common.SendEmail(FromAddress, FromName, strEmailAddress, cc, bcc, subject, body, true);
                    }
                }
                return(intNewUserRegistered);
            }
            catch
            {
                return(2);
            }
            finally
            {
                objUser = null;
            }
        }
Beispiel #7
0
        protected void btnLogin_Click(object sender, EventArgs e)
        {
            UsersBAL usersBAL = new UsersBAL();

            if (usersBAL.ValidateUser(txtusername.Text.Replace("'", "''"), txtpassword.Text.Replace("'", "''"))) //  replace single cote to avoid  sql injection atack
            {
                Session["User"] = 1;
                Response.Redirect("AddScore.aspx");
            }
        }
Beispiel #8
0
        private void DeleteRecord(int?id = null)
        {
            Hashtable _ht = new Hashtable();

            _ht = new UsersBAL().Delete(id);
            if (_ht["p_flg"].ToString() == "1")
            {
                FormCustomization_Sample.MessageBox.Show("Record Deleted Successfully", Global.MsgInfo, MessageBoxStyle.Information);
                return;
            }
        }
Beispiel #9
0
        protected void FillCombo()
        {
            DataTable dt = new UsersBAL().FillCombo();

            cmb_EventId.Items.Insert(0, "Select Any");
            cmb_EventId.SelectedIndex = 0;
            foreach (DataRow dr in dt.Rows)
            {
                cmb_EventId.Items.Add(dr["EventId"].ToString());
            }
        }
Beispiel #10
0
        private void TxtConfirmPWord_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar == 13)
            {
                UsersDAL ud     = new UsersDAL();
                UsersBAL ub     = new UsersBAL();
                string   UName  = TxtUName.Text.Trim();
                int      Result = ud.UserNameValidation(UName);

                if (TxtUName.Text.Trim() != "")
                {
                    if (Result == 1)
                    {
                        LblMessage.Text = "Warning! This Username is Not Available";
                    }
                    else
                    {
                        if (TxtPWord.Text.Trim() != "")
                        {
                            if (TxtPWord.Text.Trim() == TxtConfirmPWord.Text.Trim())
                            {
                                ub.Username = TxtUName.Text.Trim();
                                ub.Password = TxtPWord.Text.Trim();
                                int Re = ud.AddUsers(ub);
                                if (Re > 0)
                                {
                                    MessageBox.Show("User Added Successfully");
                                    LoadDGVUsers();
                                }
                                else
                                {
                                    MessageBox.Show("Something went wrong");
                                    LoadDGVUsers();
                                }
                            }
                            else
                            {
                                MessageBox.Show("Both Password Should be Same");
                            }
                        }
                        else
                        {
                            MessageBox.Show("Password cannot be blank");
                        }
                    }
                }
                else
                {
                    MessageBox.Show("Username cannot be blank");
                }
            }
        }
Beispiel #11
0
        public int SendMailForRenewPassword(string strEmail)
        {
            try
            {
                UsersBAL   objUser       = new UsersBAL();
                UsersModel objUsersModel = objUser.FindUser(strEmail);

                if (objUsersModel == null)
                {
                    return(1);
                }


                //Update encode string in database
                objUser.UpdateUserStatus(objUsersModel.ID, objUsersModel.Status, Common.GetSHA1HashData(objUsersModel.EmailAddress));


                //Send email to user, from XSTL
                emailModel        objEmailmodel = new emailModel();
                emailBAL          objEmailBAL   = new emailBAL();
                List <emailModel> lstemailmodel = objEmailBAL.FindEmail("MyTP-Confirm-Reset-JAPA");

                if (lstemailmodel.Count > 0)
                {
                    DataTable DT = Common.ListToDataTable(lstemailmodel);
                    if (DT != null)
                    {
                        DataRow     DR       = DT.Rows[0];
                        string      FileName = ConfigurationManager.AppSettings["EmailTemplatePath"] + Convert.ToString(DR["html_xslt_file"]);
                        XmlDocument xd       = new XmlDocument();
                        xd.LoadXml("<tbdoc><encodestring>" + Server.UrlEncode(Common.GetSHA1HashData(objUsersModel.EmailAddress)) + "</encodestring></tbdoc>");
                        string body = RunXSLTransform(FileName, xd).ToHtmlString();

                        string FromAddress = Convert.ToString(DR["from_address"]);
                        string FromName    = Convert.ToString(DR["from_name"]);
                        string subject     = Convert.ToString(DR["subject"]);
                        string cc          = Convert.ToString(DR["cc"]);
                        string bcc         = Convert.ToString(DR["bcc"]);

                        Common.SendEmail(FromAddress, FromName, objUsersModel.EmailAddress, cc, bcc, subject, body, true);
                        return(0);
                    }
                }

                return(2);
            }
            catch
            {
                return(2);
            }
        }
        protected void BtnSave_Click(object sender, EventArgs e)
        {
            string email = Mail.Text;

            bool     result     = false;
            UsersBAL usersLogic = new UsersBAL();

            result = usersLogic.AddUser(email);

            if (result == true)
            {
                SaveLabel.Text = "User added";
            }
        }
Beispiel #13
0
        public ActionResult Login2(UsersDTO usersDTO)
        {
            bool          status   = false;
            List <string> messages = new List <string>();

            if (UsersBAL.ValidateUser(usersDTO))
            {
                usersDTO            = UsersBAL.GetUserByLogin(usersDTO.Login);
                Session["UserId"]   = usersDTO.Id;
                Session["UserName"] = usersDTO.Name;
                return(Redirect("~/Home/Index"));
            }
            messages.Add("Invalid Login/Password combination.");
            ViewBag.Status   = status;
            ViewBag.Messages = messages;
            return(View(usersDTO));
        }
Beispiel #14
0
        /// <summary>
        /// ChangePassword
        /// </summary>
        /// <param name="strEmailAddress"></param>
        /// <param name="strOldPassword"></param>
        /// <param name="strNewPassword"></param>
        /// <returns></returns>
        public int ChangePasswordMethod(string strEmailAddress, string strOldPassword, string strNewPassword)
        {
            UsersBAL objUsersBAL         = new UsersBAL();
            int      successfullyUpdated = 0;

            try
            {
                List <UsersModel> lstUsersModel = objUsersBAL.GetPasswordByEmail(strEmailAddress);
                if (lstUsersModel != null && lstUsersModel.Count > 0)
                {
                    foreach (UsersModel obj in lstUsersModel)
                    {
                        if (obj.Password == strOldPassword)
                        {
                            obj.Password        = strNewPassword;
                            obj.encodestring    = "";
                            obj.Status          = "confirm";
                            successfullyUpdated = objUsersBAL.SaveUser(obj);
                            if (successfullyUpdated == 1)
                            {
                                return(1);
                            }
                        }
                        else
                        {
                            return(0); // Either email address not registered or old password is incorrect.
                            //  return RedirectToAction("Message", "MessageDisplay", new { E = 44 });
                        }
                    }
                }
                else
                {
                    return(0); // Either email address not registered or old password is incorrect.
                    //  return RedirectToAction("Message", "MessageDisplay", new { E = 44 });
                }
                return(0);
            }
            catch (Exception)
            {
                return(2);
            }
            finally
            {
                objUsersBAL = null;
            }
        }
Beispiel #15
0
        /// <summary>
        /// RegisterNewUser
        /// </summary>
        /// <param name="strEmailAddress"></param>
        /// <param name="password"></param>
        /// <returns></returns>
        public int UpdateUserStatus(Int32 UsersID, string strStatus, string encodestring)
        {
            UsersBAL objUser = new UsersBAL();

            try
            {
                int iUpdateSuccessfully = objUser.UpdateUserStatus(UsersID, strStatus, encodestring);
                return(iUpdateSuccessfully);
            }
            catch
            {
                return(2);
            }
            finally
            {
                objUser = null;
            }
        }
Beispiel #16
0
        protected void btnLogin_Click(object sender, EventArgs e)
        {
            UserLogin usr = new UserLogin();

            usr.Username = txtUserId.Text;
            usr.Password = txtPassword.Text;
            UsersBAL usersBAL = new UsersBAL();
            DataSet  ds       = usersBAL.UserLogins(usr);

            if (ds != null && ds.Tables.Count > 0)
            {
                //Add to session
                Session["ClientId"]    = string.IsNullOrEmpty(ds.Tables[0].Rows[0]["ClientId"].ToString()) ? 0 : ds.Tables[0].Rows[0]["ClientId"];
                Session["UserEmailId"] = ds.Tables[0].Rows[0]["UserEmailId"];
                Session["UserName"]    = ds.Tables[0].Rows[0]["UserName"];
                Session["BranchId"]    = ds.Tables[0].Rows[0]["BranchId"];
                Session["BranchName"]  = ds.Tables[0].Rows[0]["BranchName"];
                Session["UserTypeId"]  = ds.Tables[0].Rows[0]["UserTypeId"];
                //Session["ServiceCompanyId"] = string.IsNullOrEmpty(ds.Tables[0].Rows[0]["ServiceCompanyId"].ToString()) ? 0 : ds.Tables[0].Rows[0]["ServiceCompanyId"];
                Session["BranchName"] = ds.Tables[0].Rows[0]["BranchName"];
                Session["ClientName"] = ds.Tables[0].Rows[0]["ClientName"];
                Session["ClientLogo"] = ds.Tables[0].Rows[0]["ClientLogo"];
                //Session["ServiceCompany"] = ds.Tables[0].Rows[0]["ServiceCompany"];
                Session["UserId"] = ds.Tables[0].Rows[0]["UserId"];
                Session["IsServiceCompanyUser"] = ds.Tables[0].Rows[0]["IsServiceCompanyUser"];
                Session["UserTypeName"]         = ds.Tables[0].Rows[0]["UserTypeName"];
                Session["UserTypeCode"]         = ds.Tables[0].Rows[0]["UserTypeCode"];

                if (Session["IsServiceCompanyUser"].ToString() == "1" || Session["IsServiceCompanyUser"].ToString() == "true" ||
                    Session["IsServiceCompanyUser"].ToString() == "True")
                {
                    Session["ServiceCompanyId"] = string.IsNullOrEmpty(ds.Tables[0].Rows[0]["ClientId"].ToString()) ? 0 : ds.Tables[0].Rows[0]["ClientId"];
                }
                else
                {
                    Session["ServiceCompanyId"] = "0";
                }

                Response.Redirect("/ModuleUI/joblist.aspx");
            }
            else
            {
            }
        }
Beispiel #17
0
        public ActionResult EmailLogin(FormCollection formCollection)
        {
            string strEMailAddress = "";
            string strPassword     = "";

            foreach (string key in formCollection.Keys)
            {
                if (key == "email")
                {
                    strEMailAddress = formCollection[key].Trim();
                }
                else if (key == "password")
                {
                    strPassword = formCollection[key].Trim();
                }
            }
            Session["LoginEmailAddress"] = null;
            if (strEMailAddress != "" && strPassword != "" && strEMailAddress.ToLower() != "email address")
            {
                UsersBAL          objUserBAL    = new UsersBAL();
                List <UsersModel> lstUsersModel = objUserBAL.FindUser(strEMailAddress, strPassword);
                if (lstUsersModel != null && lstUsersModel.Count > 0)
                {
                    if (lstUsersModel[0].Status == "confirm")
                    {
                        Session["LoginEmailAddress"] = strEMailAddress;
                        return(RedirectToAction("BookingList", "Bookings"));
                    }
                    else
                    {
                        return(RedirectToAction("Message", "MessageDisplay", new { E = 50 }));
                    }
                }
                else
                {
                    return(RedirectToAction("Message", "MessageDisplay", new { E = 37 }));
                }
            }
            else
            {
                return(RedirectToAction("Message", "MessageDisplay", new { E = 2 }));
            }
        }
Beispiel #18
0
        private void PBoxUpdate_Click(object sender, EventArgs e)
        {
            UsersBAL ub = new UsersBAL();
            UsersDAL ud = new UsersDAL();

            if (DGVUsers.SelectedRows.Count > 0)
            {
                ub.UserID   = Convert.ToInt32(DGVUsers.SelectedRows[0].Cells[0].Value + string.Empty);
                ub.Username = TxtUsername.Text.Trim();
                ub.Password = TxtPassword.Text.Trim();
                int Result = ud.UpdateUsers(ub);
                if (Result == 1)
                {
                    MessageBox.Show("Updated Successfully");
                    LoadDGVUsers();
                }
                else
                {
                    MessageBox.Show("Oops Something went wrong");
                }
            }
        }
Beispiel #19
0
        protected void LoginBtn_Click(object sender, EventArgs e)
        {
            string        log_email  = Mail.Text;
            UsersBAL      usersLogic = new UsersBAL();
            List <string> users      = new List <string>();

            users = usersLogic.GetUsersList();

            for (int i = 0; i < users.Count; i++)
            {
                if (users[i] == log_email)
                {
                    //login;
                    LoginLabel.Text  = "Success";
                    Session["email"] = users[i];
                    break;
                }
                else
                {
                    LoginLabel.Text = "Wrong username";
                }
            }
        }
Beispiel #20
0
        private void SaveData()
        {
            Hashtable _ht = new Hashtable();

            try
            {
                if (CheckFormValidation())
                {
                    if (_strActionType == "Add")
                    {
                        _ht = new UsersBAL().Add(new string[] { txt_UserName.Text.Trim(), Global.EncryptedPassword(txt_Password.Text.Trim()),
                                                                cmb_EventId.Text, cmb_UserType.Text,
                                                                null, Global.UserId });
                        if (_ht["p_flg"].ToString() == "1")
                        {
                            FormCustomization_Sample.MessageBox.Show("Saved Successfully", Global.MsgInfo, MessageBoxStyle.Information);
                            return;
                        }
                    }
                    else if (_strActionType == "Edit")
                    {
                        _ht = new UsersBAL().Update(new string[] { txt_UserName.Text.Trim(), Global.EncryptedPassword(txt_Password.Text.Trim()),
                                                                   cmb_EventId.Text, cmb_UserType.Text,
                                                                   null, Global.UserId, lblUserId.Text });
                        if (_ht["p_flg"].ToString() == "1")
                        {
                            FormCustomization_Sample.MessageBox.Show("Updated Successfully", Global.MsgInfo, MessageBoxStyle.Information);
                            return;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
Beispiel #21
0
    public string GetAllUsers()
    {
        UsersBAL users = new UsersBAL();

        return(users.GetAllUsers());
    }
    protected void LoadUserRights()
    {
        UsersBAL     usersBal     = new UsersBAL();
        UserRightsEn userRightsEn = new UserRightsEn();

        userRightsEn = usersBal.GetUserRights(Convert.ToInt32(Request.QueryString["Menuid"]), Convert.ToInt32(Session[Helper.UserGroupSession]));

        if (userRightsEn.IsAdd)
        {
            ibtnSave.Enabled = true;
        }
        else
        {
            ibtnNew.Enabled     = false;
            ibtnNew.ImageUrl    = "../images/gAdd.png";
            ibtnNew.ToolTip     = "Access Denied";
            ibtnDelete.Enabled  = false;
            ibtnDelete.ImageUrl = "../images/gdelete.png";
            ibtnDelete.ToolTip  = "Access Denied";
            ibtnFirst.Enabled   = false;
            ibtnLast.Enabled    = false;
            ibtnPrevs.Enabled   = false;
            ibtnNext.Enabled    = false;
            ibtnFirst.ToolTip   = "Access Denied";
            ibtnLast.ToolTip    = "Access Denied";
            ibtnPrevs.ToolTip   = "Access Denied";
            ibtnNext.ToolTip    = "Access Denied";
            ibtnFirst.ImageUrl  = "../images/gnew_first.png";
            ibtnLast.ImageUrl   = "../images/gnew_last.png";
            ibtnPrevs.ImageUrl  = "../images/gnew_Prev.png";
            ibtnNext.ImageUrl   = "../images/gnew_next.png";
            ibtnSave.Enabled    = false;
            ibtnSave.ImageUrl   = "../images/gsave.png";
            ibtnSave.ToolTip    = "Access Denied";
        }

        if (userRightsEn.IsEdit)
        {
            Session["EditFlag"] = true;
        }
        else
        {
            Session["EditFlag"] = false;
        }

        ibtnView.Enabled = userRightsEn.IsView;

        if (userRightsEn.IsView)
        {
            ibtnView.ImageUrl = "../images/find.png";
            ibtnView.Enabled  = true;
        }
        else
        {
            ibtnView.ImageUrl = "../images/gfind.png";
            ibtnView.ToolTip  = "Access Denied";
        }

        ibtnPrint.Enabled = userRightsEn.IsPrint;

        if (userRightsEn.IsPrint)
        {
            ibtnPrint.Enabled  = true;
            ibtnPrint.ImageUrl = "../images/print.png";
            ibtnPrint.ToolTip  = "Print";
        }
        else
        {
            ibtnPrint.Enabled  = false;
            ibtnPrint.ImageUrl = "../images/gprint.png";
            ibtnPrint.ToolTip  = "Access Denied";
        }

        if (userRightsEn.IsOthers)
        {
            ibtnOthers.Enabled  = true;
            ibtnOthers.ImageUrl = "../images/others.png";
            ibtnOthers.ToolTip  = "Others";
        }
        else
        {
            ibtnOthers.Enabled  = false;
            ibtnOthers.ImageUrl = "../images/gothers.png";
            ibtnOthers.ToolTip  = "Access Denied";
        }

        if (userRightsEn.IsPost)
        {
            ibtnPosting.Enabled  = true;
            ibtnPosting.ImageUrl = "../images/posting.png";
            ibtnPosting.ToolTip  = "Posting";
        }
        else
        {
            ibtnPosting.Enabled  = false;
            ibtnPosting.ImageUrl = "../images/gposting.png";
            ibtnPosting.ToolTip  = "Access Denied";
        }
    }
Beispiel #23
0
        private void LoadData()
        {
            DataTable Dt = new UsersBAL().LoadAll();

            BindData(Dt);
        }
Beispiel #24
0
        private void SearchData(string username)
        {
            DataTable dt = new UsersBAL().LoadAll(username);

            BindData(dt);
        }
Beispiel #25
0
        public ActionResult Register(FormCollection formCollection, bool captchaValid)
        {
            if (ModelState.IsValid && captchaValid)
            {
                UsersBAL objUserBAL = new UsersBAL();
                logger.Debug("Register New User");
                string userName = "", emailAddress = "", password = "", confirmPassword = "";
                foreach (string key in formCollection.Keys)
                {
                    if (key == "username")
                    {
                        userName = formCollection[key].Trim();
                    }
                    else if (key == "email")
                    {
                        emailAddress = formCollection[key].Trim();
                    }
                    else if (key == "password")
                    {
                        password = formCollection[key].Trim();
                    }
                    else if (key == "confirmpassword")
                    {
                        confirmPassword = formCollection[key].Trim();
                    }
                }

                logger.Debug("Validations check");
                if (string.IsNullOrEmpty(emailAddress) || string.IsNullOrEmpty(password) || string.IsNullOrEmpty(confirmPassword))
                {
                    return(RedirectToAction("Message", "MessageDisplay", new { E = 41 }));
                }

                if (password.Length < 6)
                {
                    return(RedirectToAction("Message", "MessageDisplay", new { E = 46 }));
                }

                if (Common.ValidateEmailAddress(emailAddress) == false)
                {
                    return(RedirectToAction("Message", "MessageDisplay", new { E = 40 }));
                }

                if (password != confirmPassword)
                {
                    return(RedirectToAction("Message", "MessageDisplay", new { E = 36 }));
                }

                logger.Debug("check user already exist or not");
                int retValue = UserAlreadyExist(emailAddress);
                if (retValue == 1)
                {
                    return(RedirectToAction("Message", "MessageDisplay", new { E = 42 }));
                }
                else if (retValue == 2)
                {
                    return(RedirectToAction("Message", "MessageDisplay", new { E = 43 }));
                }

                logger.Debug("If user not already exist then register new user");
                if (retValue == 0)
                {
                    int NewUserRegistered = RegisterNewUser(emailAddress, password, Common.GetSHA1HashData(emailAddress));


                    if (NewUserRegistered == 1)
                    {
                        return(RedirectToAction("Message", "MessageDisplay", new { E = 39 }));
                    }
                    else
                    {
                        return(RedirectToAction("Message", "MessageDisplay", new { E = 43 }));
                    }
                }
            }

            if (!captchaValid)
            {
                return(RedirectToAction("Message", "MessageDisplay", new { E = 48 }));
            }


            return(View());
        }