Vicomi


-------------------------------- Home Controller ---------------------------------

public ActionResult Index()
        {
            Session.RemoveAll();
            return View();
        }

        //--------------------------------------------------------------------------------

        [HttpPost]
        public ActionResult Index(Login model, string returnUrl)
        {
            // Assign value into session

            DataManager dataManager = new DataManager();

            if (ModelState.IsValid)
            {

                bool flag = (model.rememberMe); // setting remember me check box - test lakshika

                FormsAuthentication.SetAuthCookie(model.userName, flag);
                 //xxxxx   if (Url.IsLocalUrl(returnUrl) && returnUrl.Length > 1 && returnUrl.StartsWith("/")
                 //  xxxxx     && !returnUrl.StartsWith("//") && !returnUrl.StartsWith("/\\"))

              //  if ((model.userName == "GR201300003") && (model.password == "GR201300003"))
                if (dataManager.Login_Check(model.userName,model.password)==true)
                    {
                        //var vSessionValue = new Login();

                        Session["SessionUserName"] = dataManager.studentIDtoName(model.userName);

                        Session["SessionUserID"] = model.userName;

                        return RedirectToAction("ViewPage");
                   
                    }
                    else
                    {
                       // ModelState.AddModelError("", "The user name or password provided is incorrect.");

                        ModelState.AddModelError("aaa", "adfdghdghgdhgdhdgda");
                        ViewBag.error = "Lakshika";
                        return RedirectToAction("Index", "Home","asaas");
                    }

            }
            else
            {
               // model.error_msg = model.update_content(model);
             

                return RedirectToAction("Index");
            }
        }



        public ActionResult ViewPage(Login model)
        {
            // Create object of model call for call properties and set value - lakshika345
            var vSessionValue = new Login();
            try
            {
               

                // check existing value into session (tested)
                if ((Object)Session["SessionUserID"] != null)
                {
                    vSessionValue.userName = model.userName;
                    vSessionValue.password = model.password;


                      vSessionValue.sSessionValue = "You are logged in as " + Session["SessionUserID"].ToString();

                      vSessionValue.sSessionValueName = Session["SessionUserName"].ToString().Replace("   ", "").Replace("*", ""); ;

                }
                else
                { // if session expired display the msg - tested

                    vSessionValue.sSessionValue = "Session Expired";
                    return RedirectToAction("Index");

                }

            }
            catch(Exception)
            {

            }
            // return value to view
            return View(vSessionValue);
        }

Leave a Reply

Subscribe to Posts | Subscribe to Comments

Vicomi

cmt

Contact Form

Name

Email *

Message *

Dialog

    Popular Post

    Blogger templates

    Powered by Blogger.

    - Copyright © Testing -Metrominimalist- Powered by Blogger - Designed by Johanes Djogan -