public async Task <JsonResult> DiscardFromGroup(int groupId) { try { await groups.OpenConnectionAsync(); var group = await groups.GetAsync(groupId); if (group == null) { return(Json(new { Error = "noGroup" })); } if (group.TeacherId != GetCurrentTeacherId()) { return(Json(new { Error = "notYourGroup" })); } try { await groups.RemoveTeacherFormGroup(group.Id); return(Json(new { Error = "ok" })); } catch (SqlException ex) { if (ex.Number == 50_005) { return(Json("noGroup")); } throw ex; } } finally { groups.CloseConnection(); } }