コード例 #1
0
 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"));
 }
コード例 #2
0
 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);
     }
 }
コード例 #3
0
        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));
            }
        }
コード例 #4
0
ファイル: EditTeacher.cs プロジェクト: MrK3w/StudentskySystem
        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();
        }
コード例 #5
0
 public async Task <IActionResult> DeleteConfirmed(string id)
 {
     teacherService.DeleteTeacher(id);
     return(RedirectToAction(nameof(Index)));
 }
コード例 #6
0
 public ActionResult DeleteTeacher(string teacherId)
 {
     _teacherService.DeleteTeacher(teacherId);
     return(View("ShowAllTeachers"));
 }