public async Task <IActionResult> VolunteerTrainingComplete(TrainingCompletedViewModel vm) { VolunteerRepository repo = new VolunteerRepository(configModel.ConnectionString); VolunteerTrainingModel training; VolunteerModel profile; var user = await userManager.GetUserAsync(User); // Verify the user is a staff member if (!User.IsInRole(UserHelpers.UserRoles.Staff.ToString())) { return(Utilities.ErrorJson("Not authorized")); } // Validate inputs training = repo.GetTraining(vm.TrainingId); if (training == null) { return(Utilities.ErrorJson("Invalid training id")); } profile = repo.GetVolunteer(vm.VolunteerId); if (profile == null) { return(Utilities.ErrorJson("Invalid volunteer id")); } try { repo.AddTrainingCompleted(vm.VolunteerId, vm.TrainingId); } catch (Exception e) { return(Utilities.ErrorJson(e.Message)); } return(Utilities.NoErrorJson()); }