public ActionResult NewUser(UserViewModel userViewModel)
 {
     if (!ModelState.IsValid)
     {
         userViewModel.UserViewEntity.ProviderId = int.Parse(Session["ProviderId"].ToString());
         userViewModel.UserViewEntityGrid = GetAllUsers();
         return View(userViewModel);
     }
     try
     {
         var userRepository = new UserRepository();
         userRepository.AddUser(new User
         {
             UserName = userViewModel.UserViewEntity.UserName,
             Password = EncryptDecrypt.EncryptData(userViewModel.UserViewEntity.Password, EncryptDecrypt.ReadCert()),
             ProviderId = userViewModel.UserViewEntity.ProviderId
         });
     }
     catch (Exception ex)
     {
         ModelState.AddModelError("", ex.Message);
         return View(userViewModel);
     }
     ViewBag.Message = "Created Successfully!";
     return RedirectToAction("NewUser");
 }
        public ActionResult NewUser()
        {
            if (!LogOnHelper.CheckLogOn()) return RedirectToAction("Login", "Account");

            var userViewModel = new UserViewModel();
            userViewModel.UserViewEntity.ProviderId = int.Parse(Session["ProviderId"].ToString());
            userViewModel.UserViewEntityGrid = GetAllUsers();
            return View(userViewModel);
        }
 public ActionResult RemoveUser(int userId)
 {
     var userRepository = new UserRepository();
     userRepository.RemoveUser(userId);
     var userViewModel = new UserViewModel();
     userViewModel.UserViewEntityGrid = GetAllUsers();
     return PartialView("UserGrid", userViewModel);
 }