public async Task <IActionResult> Relation(DeleteRelationModel model) { var user = await userManager.GetUserAsync(User); if (user == null || !(await userManager.IsInRoleAsync(user, UserHelpers.UserRoles.VolunteerCaptain.ToString()) || await userManager.IsInRoleAsync(user, UserHelpers.UserRoles.BusDriver.ToString()) || await userManager.IsInRoleAsync(user, UserHelpers.UserRoles.Staff.ToString()))) { return(Utilities.ErrorJson("Not authorized.")); } if (model.ChildId1 == 0 && model.ChildId2 == 0) { return(Utilities.GenerateMissingInputMessage("2 more child ids are required.")); } if (model.ChildId1 == 0 || model.ChildId2 == 0) { return(Utilities.GenerateMissingInputMessage("1 more child id is required.")); } try { ChildRepository repo = new ChildRepository(configModel.ConnectionString); return(new JsonResult(new { Message = repo.DeleteRelation(model) })); } catch (Exception exc) { return(new JsonResult(new { Error = exc.Message, })); } }