public ActionResult LogIn(LoginViewModel model, string returnUrl)
        {
            {
                //do lots of stuff
                //Create username remember cookie
                if (model.RememberMe)
                {
                    HttpCookie ckEmail = new HttpCookie("Email");
                    ckEmail.Expires = DateTime.Now.AddSeconds(500);
                    ckEmail.Value   = model.Email;
                    Response.Cookies.Add(ckEmail);
                }
            }
            NetUsers netuser = new NetUsers();

            try
            {
                if (model.Email != null && model.Password != null && model.RememberMe != null)
                {
                    using (SiplDatabaseEntities objSiplDatabaseEntities = new SiplDatabaseEntities())
                    {
                        //To Encode Password enter by User to match it with Database
                        var keyNew   = "Test";
                        var password = Helper.EncodePassword(model.Password, keyNew);
                        //To check Email & Password From DB
                        var obj = objSiplDatabaseEntities.NetUsers.Where
                                      (u => u.Email == model.Email && u.Password == password)
                                  .FirstOrDefault();

                        if (obj != null)
                        {
                            FormsAuthentication.SetAuthCookie(model.Email, true);
                            var isAdmin = (from role in objSiplDatabaseEntities.NetRoles
                                           join user in objSiplDatabaseEntities.UserRole
                                           on role.RoleId equals user.RoleId
                                           where user.UserId == obj.UserId
                                           select role.RoleName).FirstOrDefault();


                            if (isAdmin == "Admin")
                            {
                                Session["RoleId"]   = 3;
                                Session["RoleName"] = "Admin";
                                return(RedirectToAction("UserSearchView", "Admin/TeacherInfo"));
                            }
                            else if (isAdmin == "Teacher")
                            {
                                Session["RoleId"]   = 1;
                                Session["RoleName"] = "Teacher";
                                return(RedirectToAction("TeacherProfile", "Admin/TeacherInfo", new { id = obj.UserId }));
                            }
                            else if (isAdmin == "Student")
                            {
                                Session["RoleId"]   = 2;
                                Session["RoleName"] = "Student";
                                return(RedirectToAction("UserProfile", "Admin/TeacherInfo", new { id = obj.UserId }));
                            }
                            else
                            {
                                Session["Email"]    = null;
                                Session["Password"] = null;
                                return(View(model));
                            }
                        }
                        else
                        {
                            ModelState.AddModelError("Email", "Email and Password not found or matched");
                            return(View(model));
                        }
                    }
                }

                else
                {
                    return(View(model));
                }
                {
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Exception source: {0} Login Failed", ex.Message);
                return(View());
            }
        }