Exemplo n.º 1
0
        public ActionResult Edit(string Token)
        {
            UserMaster obj = new UserMaster();

            try
            {
                if (Token == null || Token.ToString().Trim().Length <= 0)
                {
                    return(RedirectToAction("Index"));
                }

                int id = SaraiBooking.App_Start.Common.GetDataFromEncryptedToken(Token, "ID", 0);

                if (id > 0)
                {
                    ViewBag.PageHeader      = "Edit " + page;
                    ViewBag.Page            = page;
                    ViewBag.AccordineHeader = page;

                    obj = facade.GetDetailById(id);
                }
                else
                {
                    ViewBag.PageHeader      = "Create " + page;
                    ViewBag.Page            = page;
                    ViewBag.AccordineHeader = page;

                    obj.PageSize   = 10;
                    obj.DateFormat = "MMM dd, yyyy";
                }

                ViewBag.DateFormatList = UserDateFormatList(obj.DateFormat);
                ViewBag.PageNumber     = SaraiBooking.App_Start.Common.GetDataFromEncryptedToken(Token, "PAGE_NUMBER", 0);
                ViewBag.MenuId         = SaraiBooking.App_Start.Common.GetDataFromEncryptedToken(Token, "MENU_ID", 0);

                return(View(obj));
            }
            catch (Exception ex)
            {
                ViewBag.ErrorMessage = MvcHtmlString.Create(SaraiBooking.App_Start.Common.RefineErrorMessage(ex.Message));
                return(View(obj));
            }
        }
Exemplo n.º 2
0
        public ActionResult Index()
        {
            UserMaster             userMaster             = new UserMaster();
            UserMasterFacade       facade                 = new UserMasterFacade();
            BlockedIPAddressFacade blockedIPAddressFacade = new BlockedIPAddressFacade();

            try
            {
                // Code for validating the CAPTCHA
                if (Request.Form["txtCaptcha"] != HttpContext.Session["CaptchaString"].ToString())
                {
                    ViewBag.CredentialError = "Sorry! Invalid Captcha";
                    return(View());
                }


                userMaster.EmailId  = Request.Form["txtUserName"];
                userMaster.Password = Request.Form["txtPassword"];

                #region Authenticate Username and Passowrd

                int Id = facade.ValidateUserCredentials(userMaster, Request.ServerVariables["REMOTE_ADDR"].ToString(), Request.Url.Scheme + "://" + Request.Url.Host + ":" + Request.Url.Port, UserType.GURUDWARA);

                //If Id is less than or Equal to ZERO, then Invalid Username or Password
                if (Id <= 0)
                {
                    ViewBag.CredentialError = "Invalid Credentials. To generate new password, use Forgot Password option.";
                }


                if (Id > 0)
                {
                    userMaster                    = facade.GetDetailById(Id);
                    userMaster.UserType           = UserType.GURUDWARA;
                    userMaster.IPAddress          = Request.ServerVariables["REMOTE_ADDR"].ToString();
                    userMaster.BrowserInformation = Request.ServerVariables["HTTP_USER_AGENT"].ToString();

                    Session.Timeout = 60;

                    Session[Session["APP_PREFIX"] + "_SessionId"]           = Session.SessionID;
                    Session[Session["APP_PREFIX"] + "_USER_MASTER_SESSION"] = userMaster;

                    //Check for Extra Security Checks
                    if (facade.isValidLoginDaysAndTime(userMaster))
                    {
                        if (userMaster.ExtraSecurityRequired)
                        {
                            CommonFacade facadeCommon     = new CommonFacade();
                            string       verificationCode = facadeCommon.CreateRandomCode(6, true);

                            facade.MailVerificationCode(userMaster, verificationCode, Server.MapPath("~/EmailTemplates/VerificationCode.htm"));

                            return(RedirectToAction("Security", "Home", new { Token = SaraiBooking.App_Start.Common.EncryptData("`VERIFICATION_CODE=" + verificationCode + "`RECORD_STATUS=VCSS") }));
                        }
                        else
                        {
                            userMaster.LoginHistoryId = facade.SaveLoginSessionHistory();

                            Session[Session["APP_PREFIX"] + "_USER_MASTER_SESSION"] = userMaster;

                            return(RedirectToAction("About", "AboutUs"));
                        }
                    }
                }
                #endregion
            }
            catch (Exception ex)
            {
                Session[Session["APP_PREFIX"] + "_SessionId"]           = null;
                Session[Session["APP_PREFIX"] + "_USER_MASTER_SESSION"] = null;

                ViewBag.CredentialError = ex.Message;
            }

            return(View(userMaster));
        }