public ActionResult Delete(string id) { string loggedInUserID = Convert.ToString(Session["userid"]); if (id == loggedInUserID) { ToastrNotificationService.AddWarningNotification("You can not delete yourself", null); } else { accountRepository.DeleteUser(id); ToastrNotificationService.AddSuccessNotification("User deleted successfully", null); } return(RedirectToAction("Index")); }
public async Task <ActionResult> ChangePassword(ChangePasswordDto changePasswordDto) { if (ModelState.IsValid) { string userid = Convert.ToString(HttpContext.Session["userid"]); if (!string.IsNullOrEmpty(userid)) { if (changePasswordDto.Password == changePasswordDto.NewPassword) { ToastrNotificationService.AddWarningNotification("Password and New Password can't be same", null); } else if (changePasswordDto.NewPassword != changePasswordDto.ConfirmPassword) { ToastrNotificationService.AddWarningNotification("New Password and Confirm Password must be same", null); } else { var user = accountRepository.GetUserByID(userid); if (user != null) { if (user.Password == changePasswordDto.Password) { await accountRepository.ChangePassword(changePasswordDto); ToastrNotificationService.AddSuccessNotification("Password changed successfully", null); return(RedirectToAction("Index", "Home")); } else { ToastrNotificationService.AddWarningNotification("Invaild Password", null); ModelState.AddModelError("Password", "Invaild Password"); } } } } } return(View(changePasswordDto)); }