public async Task <IActionResult> ConvertToAlumni()
        {
            User user = await HttpContext.GetContextUser(userService)
                        .ConfigureAwait(false);

            if (await userService.FindAsync(user.Id) == null)
            {
                ProblemDetails problem = new ProblemDetails
                {
                    Title    = "Failed getting the user account.",
                    Detail   = "The database does not contain a user with this user id.",
                    Instance = "598E61EC-1C0F-4ED2-AC42-F5B5503D4A5E"
                };
                return(NotFound(problem));
            }

            List <UserTask> userTasks = await userTaskService.GetUserTasksForUser(user.Id);

            UserTask userTask = userTasks.Find(u => u.Type == UserTaskType.GraduationReminder);

            if (userTask == null ||
                userTask.Status == UserTaskStatus.Completed)
            {
                ProblemDetails problem = new ProblemDetails
                {
                    Title  = "No graduation user task exists.",
                    Detail =
                        "The database does not contain a (uncompleted) user task for graduating.",
                    Instance = "A10E4AE8-633D-4334-BADA-99B7AD077B6D"
                };
                return(NotFound(problem));
            }

            List <Role> roles = await roleService.GetAllAsync();

            Role alumniRole = roles.Find(r => r.Name == "Alumni");

            if (alumniRole == null)
            {
                ProblemDetails problem = new ProblemDetails
                {
                    Title    = "Alumni role does not exist.",
                    Detail   = "The database does not contain a role for alumni.",
                    Instance = "2DE31766-5D9C-4E41-908F-389A9A85F723"
                };
                return(NotFound(problem));
            }


            // Rest call to Identity server to change credentials. Credentials are in the headers due to security issues.
            identityHttpClient.DefaultRequestHeaders.Add("password",
                                                         Request.Headers.FirstOrDefault(h => h.Key == "password")
                                                         .Value.FirstOrDefault());
            identityHttpClient.DefaultRequestHeaders.Add("email",
                                                         Request.Headers.FirstOrDefault(h => h.Key == "email")
                                                         .Value.FirstOrDefault());
            identityHttpClient.DefaultRequestHeaders.Add("subjectId", user.IdentityId);
            HttpResponseMessage resp = await identityHttpClient.PutAsync("ExternalAccount", new StringContent(""));

            if (!resp.IsSuccessStatusCode)
            {
                ProblemDetails problem = new ProblemDetails
                {
                    Title    = "IdentityServer had an error.",
                    Detail   = resp.ReasonPhrase,
                    Instance = "94B362FE-F038-43AF-B2C3-462513D1C7F8"
                };
                return(StatusCode(503, problem));
            }

            userTask.Status = UserTaskStatus.Completed;
            userTaskService.Update(userTask);


            user.Role  = alumniRole;
            user.Email = Request.Headers.FirstOrDefault(h => h.Key == "email")
                         .Value.FirstOrDefault();
            userService.Update(user);

            userTaskService.Save();
            userService.Save();
            return(Ok(user));
        }
 public UserTask Save([FromBody] UserTask userTask)
 {
     return(_userTaskService.Save(userTask));
 }