public ActionResult Create()
 {
     var permissionRepository = InstantiatePermissionRepository;
     UserViewModel userViewModel = new UserViewModel
     {
         Permission = GetPermissionLoaded(InstantiatePermissionRepository)
     };
     return View(userViewModel);
 }
        public ActionResult Delete(UserViewModel userViewModel)
        {

            if (ModelState.IsValid == Valid)
            {

                switch (InstantiateUserRepository.Deletes(userViewModel.Users))
                {
                    case Success:
                        return RedirectToAction(nameof(this.List));
                }
            }
            return View(GetUserViewFill(userViewModel.Users));
        }
        public ActionResult Create(UserViewModel userViewModel)
        {
            userViewModel.Users.LastAccess = DateTime.Now;
            if (Request.IsAjaxRequest() && ModelState.IsValid == Valid)
            {               
                return ModelState.IsValid && InstantiateUserRepository.Creates(user: userViewModel.Users) == Success ? 
                     Json(new { result = userViewModel.Users.UserID, JsonRequestBehavior.AllowGet } ):
                     Json(new { result = 0, JsonRequestBehavior.AllowGet });
            }
            else
            {              
                if (ModelState.IsValid == Valid && InstantiateUserRepository.Creates(user: userViewModel.Users) == Success)
                {
                    return RedirectToAction(nameof(this.List));
                }
                return View(GetUserViewFill(userViewModel.Users));
            }

        }
 public UserViewModel GetUserViewFill(Users user)
 {
     UserViewModel userViewModel = new UserViewModel
     {
         Users = user,
         Permission = GetPermissionLoaded(InstantiatePermissionRepository, user.PermissionID)
     };
     return userViewModel;
 }