public async Task <IActionResult> DropTeacher(int id) { var teacherDiscipline = await _context.TeacherDisciplines.FindAsync(id); var disciplineId = teacherDiscipline.DisciplineId; _context.Remove(teacherDiscipline); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Edit), new { id = disciplineId })); }
public async Task <IActionResult> DeleteEvent(int eventId) { var ev = await _context.Events.FindAsync(eventId); if (ev == null) { return(NotFound()); } if (!_context.EventLogs.Any(x => x.EventId == ev.Id)) { _context.Remove(ev); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Edit), new { id = ev.SchedulePlanId })); } ModelState.AddModelError("EventLogs", "Невозможно удалить мероприятиe, по которому проставлены оценки."); return(await Edit(ev.SchedulePlanId)); }