Exemple #1
0
 public ActionResult UserAccountGridViewPartialUpdate(ManageUserViewModel item)
 {
     
     if (ModelState.IsValid)
     {
         try
         {
             var user = UserManager.FindByName(item.UserName);                    
             if (user != null)
             {
                 string newPassword = item.NewPassword;
                 string newHasPassword = UserManager.PasswordHasher.HashPassword(newPassword);
                 user.PasswordHash = newHasPassword;
                 var check = UserManager.Update(user);
                 if(!check.Succeeded)
                 {
                     ViewData["EditError"] = "Lỗi cập nhập mật khẩu";
                 }
             }
             else
             {
                 ViewData["EditError"] = "Tên người dùng không tồn tại";
             }
             
         }
         catch (Exception e)
         {
             ViewData["EditError"] = e.Message;
         }
     }
     else
         ViewData["EditError"] = "Lổi, kiểm tra thông tin nhập.";
    
     var users = userService.GetUsers();
     var model = new List<ManageUserViewModel>();
     foreach (var user in users)
     {
         var u = new ManageUserViewModel(user);
         var companies = companyService.GetCompaniesByUser(user);
         u.CompaniesList = companies.ToList();
         model.Add(u);
     }
     return PartialView("_UserAccountGridViewPartial", model);
 }
Exemple #2
0
 public ActionResult UserAccountGridViewPartialDelete(System.String UserName)
 {
     
     if (UserName != null)
     {
         try
         {
             var user = UserManager.FindByName(UserName);
             if (user != null)
             {
                 UserManager.Delete(user);
             }
             else
             {
                 ViewData["EditError"] = "Tên người dùng không tồn tại";
             }
             // Insert here a code to delete the item from your model
         }
         catch (Exception e)
         {
             ViewData["EditError"] = e.Message;
         }
     }
     var users = userService.GetUsers();
     var model = new List<ManageUserViewModel>();
     foreach (var user in users)
     {
         var u = new ManageUserViewModel(user);
         var companies = companyService.GetCompaniesByUser(user);
         u.CompaniesList = companies.ToList();
         model.Add(u);
     }
     return PartialView("_UserAccountGridViewPartial",model);
 }
Exemple #3
0
 public ActionResult UserAccountGridViewPartial()
 {
     var users = userService.GetUsers();
     List<ManageUserViewModel> model = new List<ManageUserViewModel>();
     foreach (var user in users)
     {
         var u = new ManageUserViewModel(user);
         var companies = companyService.GetCompaniesByUser(user);
         u.CompaniesList = companies.ToList();
         model.Add(u);
     }
     
     return PartialView("_UserAccountGridViewPartial", model);
 }