public IHttpActionResult DeleteTeacher([FromUri] int teacherId) { if (!_teacherService.DeleteTeacher(teacherId)) { return(BadRequest($"ID #{teacherId} does not exist. Cannot Delete")); } return(Ok($"Teacher #{teacherId} was deleted")); }
public ActionResult Delete(int id) { try { var teacher = teacherService.GetTeacherById(id); teacherService.DeleteTeacher(teacher); return(RedirectToAction("Index")); } catch (Exception ex) { throw new Exception(ex.Message); } }
public async Task <IActionResult> DeleteTeacher() { try { var UserID = Guid.Parse(User.GetLoggedInUserId <string>()); var TeacherID = _teacherService.GetTeacherIDByUserID(UserID); var teacher = await _teacherService.DeleteTeacher(TeacherID); return(Ok("Teacher Deleted")); } catch (Exception e) { return(BadRequest(e.Message)); } }
private async void DeleteClick(object sender, EventArgs e) { if (!CheckValue()) { return; } PrepareTeacher(); try { await _teacherService.DeleteTeacher(_teacher); } catch (Exception) { MessageBox.Show(@"Cannot be deleted because teacher is probably something already teaching!"); } CloseForm(); }
public async Task <IActionResult> DeleteConfirmed(string id) { teacherService.DeleteTeacher(id); return(RedirectToAction(nameof(Index))); }
public ActionResult DeleteTeacher(string teacherId) { _teacherService.DeleteTeacher(teacherId); return(View("ShowAllTeachers")); }