public bool AddNewUser(USER user)
        {
            bool _retVal = false;

            _context.USERS.Add(user);
            _context.SaveChanges();
            _retVal = true;

            return _retVal;
        }
        public ActionResult Edit(UserViewModel model)
        {
            if (ModelState.IsValid)
            {
                USER _updateUser = new USER();
                _updateUser.ID = model.ID;
                _updateUser.USER_NAME = model.UserName;
                _updateUser.DISPLAY_NAME = model.DisplayName;
                _updateUser.USER_PASSWORD = EncryptDecrypt.Encrypt(model.ConfirmPassword);
                _updateUser.ROLE_ID = model.RoleID;
                _repository.UpdateUser(_updateUser);

                Success(string.Format("<b>{0}</b> updated successfully.", model.UserName), true);

                return RedirectToAction("Manage");
            }

            return View(model);
        }
        public ActionResult Register(UserViewModel model)
        {
            if (ModelState.IsValid)
            {
                //check if user exist
                if (_repository.IsUserExist(model.UserName.Trim()))
                {
                    Danger(string.Format("<b>{0}</b> already exist. Choose a different user name.", model.UserName), true);
                    return View(model);
                }

                USER _newUser = new USER();
                _newUser.USER_NAME = model.UserName;
                _newUser.DISPLAY_NAME = model.DisplayName;
                _newUser.USER_PASSWORD = EncryptDecrypt.Encrypt(model.ConfirmPassword);
                _newUser.ROLE_ID = 102;
                _repository.AddNewUser(_newUser);

                Success(string.Format("<b>{0}</b> user created successfully. Please login.", model.UserName), true);

                return RedirectToAction("Login", "Account");
            }

            ModelState.AddModelError("", "Invalid/incomplete data provided. Try again.");
            return View(model);
        }
        public bool UpdateUser(USER user)
        {
            bool _retVal = false;
            var _user = _context.USERS.Find(user.ID);

            if(_user != null)
            {
                _context.Entry(_user).CurrentValues.SetValues(user);
                _context.SaveChanges();
                _retVal = true;
            }

            return _retVal;
        }