public ActionResult Login(string userName, string password)
        {
            //if (ModelState.IsValid)
            //{
            //using(WebCustumerManagerAppContext dc = new WebCustumerManagerAppContext())
            //{
            //var accesValue = dc.EntityLoginUser.Where(u => u.Username.Equals(loginUser.Username) && u.Password.Equals(loginUser.Password)).FirstOrDefault();
            //if(accesValue != null)
            //{
            //Session["loggedUserId"] = accesValue.Id.ToString();
            //Session["loggedUserName"] = accesValue.Username.ToString();
            //return RedirectToAction("Index");
            //}
            //}
            //}
            //return View();
            try
            {
                using (var contex = new WebCustumerManagerAppContext())
                {
                    var getUserName = (from s in contex.EntityLoginUser where s.Username == userName || s.Email == userName select s).FirstOrDefault();

                    if (getUserName != null)
                    {
                        var hashCode = getUserName.VCodePassword;
                        var encondingPasswordString = WebCustomerManagerHelper.EncodePassword(password, hashCode);
                        var query = (from s in contex.EntityLoginUser where (s.Username == userName || s.Email == userName) && s.Password.Equals(encondingPasswordString) select s).FirstOrDefault();

                        if (query != null)
                        {
                            Session["loggedUserId"]   = query.Id.ToString();
                            Session["loggedUserName"] = query.Username.ToString();
                            return(RedirectToAction("Index"));
                        }

                        ViewBag.errormessage = "Invalid User Name or Password";
                        return(View());
                    }
                    ViewBag.errormessage = "Invalid User Name or Password";
                    return(View());
                }
            }
            catch (Exception e)
            {
                ViewBag.ErrorMessage = "Error!!! contact admin" + e;
                return(View());
            }
        }
        public ActionResult Create(EntityLoginUser entityLoginUser)
        {
            //if (ModelState.IsValid)
            //{
            //entityLoginUser.RegDate = DateTime.Now;
            //db.EntityLoginUser.Add(entityLoginUser);
            //db.SaveChanges();
            //return RedirectToAction("Index");
            //}

            //return View(entityLoginUser);
            try
            {
                using (var contex = new WebCustumerManagerAppContext())
                {
                    var checkUser = (from s in contex.EntityLoginUser where s.Username == entityLoginUser.Username || s.Password == entityLoginUser.Password select s).FirstOrDefault();
                    if (checkUser == null)
                    {
                        var keyNew   = WebCustomerManagerHelper.GeneratePassword(10);
                        var password = WebCustomerManagerHelper.EncodePassword(entityLoginUser.Password, keyNew);
                        entityLoginUser.Password      = password;
                        entityLoginUser.RegDate       = DateTime.Now;
                        entityLoginUser.VCodePassword = keyNew;
                        db.EntityLoginUser.Add(entityLoginUser);
                        db.SaveChanges();
                        ModelState.Clear();
                        return(RedirectToAction("Login"));
                    }
                    ViewBag.errorMessage = "User Already Exist!!!!!";
                    return(View());
                }
            }
            catch (Exception e)
            {
                ViewBag.errorMessage = "Some Exception occourred" + e;
                return(View());
            }
        }