public async Task <IActionResult> AcceptedProfile(ConfirmProfileViewModel model) { //deze actie kan alleen de admin uitvoeren //ingelogde user moet een admin zijn //huidige admin user object wordt opgehaald var adminid = userManager.GetUserId(HttpContext.User); var adminuser = await userManager.FindByIdAsync(adminid); //user van te beoordelen profiel wordt uit de model gehaald middels userid var userid = model.Profiles[0].Id; ApplicationUser currentUser = await userManager.FindByIdAsync(userid); if (currentUser == null) { ViewBag.ErrorMessage = $"User with Id = {userid} cannot be found"; return(View("NotFound")); } //nieuwe profiel wordt erin gezet door tempprofile over te nemen naar currentprofile else { currentUser.Street = model.Profiles[0].Street; currentUser.PhoneNumber = model.Profiles[0].PhoneNumber; currentUser.Zipcode = model.Profiles[0].Zipcode; currentUser.City = model.Profiles[0].City; currentUser.Country = model.Profiles[0].Country; currentUser.BankNumber = model.Profiles[0].BankNumber; currentUser.ProfileImageUrl = model.Profiles[0].ProfileImageUrl; currentUser.NewProfile = null; // Update the user using UpdateAsync var result = await userManager.UpdateAsync(currentUser); if (result.Succeeded) { var activeUser = userManager.FindByIdAsync(userManager.GetUserId(HttpContext.User)).Result; // activiteit wordt gelogd repox.LogActivity(activeUser, "AcceptedProfile", $"{activeUser.Firstname[0]}. {activeUser.Lastname} heeft profielverzoek van {currentUser.Firstname[0]}. {currentUser.Lastname} goedgekeurd."); // mail wordt naar gebruiker verstuurd met bericht goedkeuring mailServer.SendAcceptedProfileMail(currentUser.UserName, currentUser.Firstname, currentUser.Lastname, adminuser.Firstname, adminuser.Lastname); return(View(@"~/Views/Account/Profile/StatusProfile.cshtml")); } return(View(currentUser)); } }