public async Task <ActionResult> Edit([Bind(Exclude = "IsEmailVerified,ActivationCode,ResetPasswordCode")] User user)
        {
            string password = user.Password; // To get the unencrypted Password before hashing
            bool   status   = false;
            string message  = "";

            // Model Validation
            if (ModelState.IsValid)
            {
                #region Email Validation
                var userEmail = await context.Users.SingleOrDefaultAsync(a => a.Username == user.Username);

                var isEmailExist = IsEmailExist(user.Email);
                if (userEmail.Email != user.Email && await isEmailExist)
                {
                    ModelState.AddModelError("EmailExist", "The 'Email' entered already exist");
                    return(View(user));
                }
                #endregion

                #region Generate Activation Code
                user.ActivationCode = Guid.NewGuid();
                #endregion

                #region Password Hashing
                user.Password        = Crypto.Hash(user.Password);
                user.ConfirmPassword = Crypto.Hash(user.ConfirmPassword); //To match the Password and Confirm Password
                #endregion
                user.IsEmailVerified = false;

                #region Save data to the DataBase
                using (ABC_DBEntities context = new ABC_DBEntities())
                {
                    context.Entry(user).State = EntityState.Modified;
                    await context.SaveChangesAsync();
                }
                #endregion

                #region Send Email to the User
                SendEmail(user.Email, user.ActivationCode.ToString(), user.FirstName, user.Username, password, "VerifyUpdate");
                message = $"Account updated successfully. Account verification link has been sent to your email address:";
                ViewData.Add("Email", user.Email);
                status = true;
                #endregion
            }
            else
            {
                message = "Invalid Request";
            }

            ViewBag.Message = message;
            ViewBag.Status  = status;
            FormsAuthentication.SignOut();
            return(View(user));
        }
        public ActionResult Authenticate(ABC_WEB.Models.Client userModel)
        {
            using (ABC_DBEntities db = new ABC_DBEntities())
            {
                var LoginDetail = db.Clients.Where(x => x.Username == userModel.Username && x.Password == userModel.Password).FirstOrDefault();
                if (LoginDetail == null)
                {
                    userModel.LoginErrorMessage = "Wrong username or Password.";
                    return(View("Index", userModel));
                }
                else
                {
                    Session["userID"]   = LoginDetail.Client_ID;
                    Session["FullName"] = LoginDetail.Name;


                    return(RedirectToAction("Index", "RequestPayment"));
                }
            }
        }
        /// <summary>
        /// Get the data of the logged in user
        /// </summary>
        /// <param name="filterContext"></param>
        protected override void OnActionExecuted(ActionExecutedContext filterContext)
        {
            if (User != null)
            {
                var usernameOremail = User.Identity.Name;

                if (!String.IsNullOrEmpty(usernameOremail))
                {
                    using (ABC_DBEntities context = new ABC_DBEntities())
                    {
                        var user = context.Users.SingleOrDefault(u => u.Email == usernameOremail || u.Username == usernameOremail); // Getting the current logged in user

                        try
                        {
                            #region Getting the Full Name of the current logged in user
                            string fullName = string.Concat(new string[] { user.FirstName, " ", user.LastName });
                            ViewData.Add("FullName", fullName);
                            #endregion

                            #region Getting the User Type of the current logged in user
                            string userType = user.UserType;
                            ViewData.Add("UserType", userType);
                            #endregion

                            #region Getting the Username of the current logged in user
                            string username = user.Username;
                            ViewData.Add("Username", username);
                            #endregion
                        }
                        catch
                        {
                            FormsAuthentication.SignOut();
                            Response.Redirect("/Home/Index");
                        }
                    }
                }

                base.OnActionExecuted(filterContext);
            }
        }