public ActionResult Login(LoginVm entity)
        {
            string OldHASHValue = string.Empty;

            byte[] SALT = new byte[saltLengthLimit];

            try
            {
                using (RepshoDBE db = new RepshoDBE())
                {
                    // Ensure we have a valid viewModel to work with
                    if (!ModelState.IsValid)
                    {
                        return(View(entity));
                    }

                    //Retrive Stored HASH Value From Database According To Username (one unique field)
                    var userInfo = db.UserMasters.Where(s => s.Username == entity.Username.Trim()).FirstOrDefault();

                    //Assign HASH Value
                    if (userInfo != null)
                    {
                        OldHASHValue = userInfo.HASH;
                        SALT         = userInfo.SALT;
                    }

                    bool isLogin = CompareHashValue(entity.Password, entity.Username, OldHASHValue, SALT);

                    if (isLogin)
                    {
                        //Login Success
                        //For Set Authentication in Cookie (Remeber ME Option)
                        SignInRemember(entity.Username, entity.isRemember);

                        //Set A Unique ID in session
                        Session["UserID"] = userInfo.UserID;

                        // If we got this far, something failed, redisplay form
                        // return RedirectToAction("Index", "Dashboard");
                        return(RedirectToLocal(entity.ReturnURL));
                    }
                    else
                    {
                        //Login Fail
                        TempData["ErrorMSG"] = "Access Denied! Wrong Credential";
                        return(View(entity));
                    }
                }
            }
            catch
            {
                throw;
            }
        }
        public ActionResult Registration(RegisterVM entity)
        {
            string HASHValue = string.Empty;

            byte[] SALT = new byte[saltLengthLimit];

            try
            {
                using (RepshoDBE db = new RepshoDBE())
                {
                    // Ensure we have a valid viewModel to work with
                    if (!ModelState.IsValid)
                    {
                        return(View(entity));
                    }

                    //Retrive Stored HASH Value From Database According To Username (one unique field)
                    var userInfo = db.UserMasters.Where(s => s.Username == entity.Username.Trim()).FirstOrDefault();

                    //Assign HASH Value
                    if (userInfo == null)
                    {
                        UserMaster user = new UserMaster();
                        SALT           = Get_SALT();
                        HASHValue      = Get_HASH_SHA512(entity.Password, entity.Username, SALT);
                        user.SALT      = SALT;
                        user.HASH      = HASHValue;
                        user.Username  = entity.Username;
                        user.FirstName = entity.FirstName;
                        user.LastName  = entity.LastName;
                        user.UserEmail = entity.UserEmail;
                        db.UserMasters.Add(user);
                        db.SaveChanges();
                        ModelState.Clear();
                        return(RedirectToAction("Login", "Login"));
                    }
                    else
                    {
                        //Login Fail
                        TempData["ErrorMSG"] = "User Exists";
                        return(View(entity));
                    }
                }
            }
            catch (Exception ex)
            {
                throw;
            }
        }