Esempio n. 1
0
        public ActionResult SignUpUser(RegisterModel objRegModel, string captcha)
        {
            #region Code for Registration
            MemberAction objMember = new MemberAction();
            bool isUserExist = objMember.FindByUserName(objRegModel.UserName.Trim());

            if (isUserExist)
            {
                ModelState.AddModelError("", "User Already exist. Please change Username.");
            }
            else
            {
                bool isRegistered = objMember.Signup(objRegModel);
                if (isRegistered == true)
                {
                    #region Send Mail if Registration Successful
                    //send automated email - content of email will be decided later
                    // Creating array list for token
                    ArrayList arrTokens = new ArrayList();
                    arrTokens.Add(objRegModel.FirstName + " " + objRegModel.LastName);
                    arrTokens.Add("http://" + Request.ServerVariables["SERVER_NAME"] + "/Member/Dashboard");
                    arrTokens.Add("http://" + Request.ServerVariables["SERVER_NAME"] + "/Seed/DiscoverSeed");
                    arrTokens.Add("http://" + Request.ServerVariables["SERVER_NAME"] + "/Member/Profile");

                    // Filling mail object
                    SendMail objSendMail = new SendMail();
                    objSendMail.ToEmailId = objRegModel.UserName;
                    objSendMail.Subject = "email.member.signup.subject.content";
                    objSendMail.MsgBody = "email.member.signup.body.content";
                    objSendMail.ChangesInMessage = arrTokens;

                    objSendMail.SendEmail(objSendMail);//    SendMail.(member.username, SystemStatements.DEFAUL_EMAIL_ADDRESS, SystemStatements.EMAIL_SUBJECT_SIGNUP, "");
                    #endregion

                    return RedirectToAction("SignUpThanks", "Member");
                }
                else
                {
                    ModelState.AddModelError("", "Error occured while registration.");
                }
            }
            return View("Default");
            #endregion
        }
Esempio n. 2
0
        public ActionResult Login(RegisterModel objLoginModel, string chkRemember)
        {
            #region
            MemberAction objMember = new MemberAction();
            Member memberData = objMember.Authenticate(objLoginModel.LogUserName, objLoginModel.LogPassword);

            if (memberData != null)
            {
                if (chkRemember != null)
                {
                    //Create a new cookie, passing the name into the constructor
                    HttpCookie cookie = new HttpCookie("UserInfo");
                    HttpCookie cookie1 = new HttpCookie("PassInfo");

                    //Set the cookies value
                    cookie.Value = objLoginModel.LogUserName;
                    cookie1.Value = objLoginModel.LogPassword;

                    //Set the cookie to expire in 1 minute
                    DateTime dtNow = DateTime.Now.AddDays(30);

                    cookie.Expires = dtNow;
                    cookie1.Expires = dtNow;

                    //Add the cookie
                    Response.Cookies.Add(cookie);
                    Response.Cookies.Add(cookie1);
                }

                SessionStore.SetSessionValue(SessionStore.Memberobject, memberData);
                string requestURL = (string)SessionStore.GetSessionValue("RequestedURL");
                SessionStore.SetSessionValue("RequestedURL", null);

                if (memberData.Role.name == SystemStatements.ROLE_SUPER_ADMIN)
                {
                    if (!string.IsNullOrEmpty(requestURL))
                        return Redirect(requestURL);
                    else
                        return RedirectToAction("AdminDashboard", "Admin");
                }
                else if (memberData.Role.name == SystemStatements.ROLE_END_USER)
                {
                    if (!string.IsNullOrEmpty(requestURL))
                    {
                        //Response.Redirect(requestURL);
                        return Redirect(requestURL);
                    }
                    else
                    {
                        //return RedirectToAction("Dashboard", "Member");
                        return RedirectToAction("Default", "Member");
                    }
                }
                else
                {
                    if (!string.IsNullOrEmpty(requestURL))
                        return Redirect(requestURL);
                    else
                    {
                        //return RedirectToAction("Dashboard", "Member");
                        return RedirectToAction("Default", "Member");
                    }
                }
            }
            else
            {
                ModelState.AddModelError("", "Login failed for current user.");
            }
            return View("Default");
            #endregion
        }
Esempio n. 3
0
        /// <summary>
        /// This method is used to signup new member.
        /// </summary>
        /// <param name="UserName"></param>
        /// <param name="Password"></param>
        /// <param name="FirstName"></param>
        /// <param name="LastName"></param>
        /// <param name="OrganisationName"></param>
        /// <returns></returns>
        public string MemberSignup(string UserName, string Password, string FirstName, string LastName, string OrganisationName)
        {
            string result = "";
            MemberAction objMember = new MemberAction();
            RegisterModel rmodel = new RegisterModel();

            bool IsMemberExist = objMember.FindByUserName(UserName);
            if (IsMemberExist)
            {
                result = "Member already exist.";
            }
            else
            {
                rmodel.UserName = UserName;
                rmodel.Password = Password;
                rmodel.FirstName = FirstName;
                rmodel.LastName = LastName;
                if (!string.IsNullOrEmpty(OrganisationName))
                {
                    if (!OrganisationName.Equals("(null)"))
                        rmodel.organisationName = OrganisationName;
                }
                result = objMember.MobileSignup(rmodel);
            }

            return result;
        }
Esempio n. 4
0
        public ActionResult ForgotPassword(RegisterModel objPwdModel)
        {
            #region Send Mail for password
            MemberAction objMember = new MemberAction();
            string memberPwd = objMember.GetPwdByUserName(objPwdModel.ForgotUserName);
            if (!string.IsNullOrEmpty(memberPwd))
            {
                //send automated email - content of email will be decided later
                // Creating array list for token
                ArrayList arrTokens = new ArrayList();
                arrTokens.Add(objPwdModel.ForgotUserName);
                arrTokens.Add(memberPwd);

                // Filling mail object
                SendMail objSendMail = new SendMail();
                objSendMail.ToEmailId = objPwdModel.ForgotUserName;
                objSendMail.Subject = "email.forget.password.subject.content";
                objSendMail.MsgBody = "email.forget.password.body.content";
                objSendMail.ChangesInMessage = arrTokens;
                objSendMail.SendEmail(objSendMail);
                ViewData["Message"] = "Your password has been sent to the specified email address. Please check your email to find out the password.";

                return View("PasswordSent");
            }
            else
            {
                ViewData["Message"] = "Sorry! We could not find a user registered with that email address";
                return View("PasswordSent");
            }
            #endregion
        }
Esempio n. 5
0
        /// <summary>
        /// Method to signup for new users.
        /// </summary>
        /// <param name="rmodel"></param>
        /// <returns></returns>
        public bool Signup(RegisterModel rmodel)
        {
            #region Business Logic

            bool actionCompleted = false;
            Member member = null;
            try
            {
                member = new Member();
                member.id = Guid.NewGuid();
                member.username = rmodel.UserName;
                member.passwd = Security.Encrypt(rmodel.Password, true);
                member.firstName = rmodel.FirstName;
                member.lastName = rmodel.LastName;
                member.secretQ = rmodel.SecretQuestion;
                member.secretA = rmodel.SecretAnswer;
                member.status = SystemStatements.STATUS_ACTIVE;
                member.created = DateTime.Now;
                member.roleId = repoObj.List<Role>(x => x.name == SystemStatements.ROLE_END_USER).FirstOrDefault().id;
                member.isVerified = false;
                member.organisationName = rmodel.organisationName;
                member.Email = rmodel.UserName;
                repoObj.Create<Member>(member);

                actionCompleted = true;
            }
            catch (Exception ex)
            {
                WriteError(ex);
            }
            return actionCompleted;

            #endregion
        }