コード例 #1
0
 public bool SelectedDelete(string ids)
 {
     try
     {
         if (!string.IsNullOrEmpty(ids))
         {
             if (ids.StartsWith(","))
             {
                 ids = ids.Remove(0, 1);
             }
             if (ids.EndsWith(","))
             {
                 ids = ids.Remove(ids.Length - 1, 1);
             }
             var silinecekler = ids.Split(',');
             for (int i = 0; i < silinecekler.Length; i++)
             {
                 _LessonService.Delete(Convert.ToInt32(silinecekler[i]));
             }
             return(true);
         }
         else
         {
             return(false);
         }
     }
     catch (Exception e)
     {
         return(false);
     }
 }
コード例 #2
0
        public ActionResult Delete(Guid guid)
        {
            var lesson = _lessonService.GetByGuid(guid);

            if (lesson == null)
            {
                return(View("Error"));
            }
            var tutorLesson = _tutorLessonService.GetByTutorLesson(lesson.Guid);

            if (tutorLesson != null)
            {
                _tutorLessonService.Delete(tutorLesson.Id);
            }
            _lessonService.Delete(lesson.Id);

            var user = _kullaniciService.GetById(Convert.ToInt32(User.Claims.Where(c => c.Type == ClaimTypes.Name)
                                                                 .Select(c => c.Value)
                                                                 .SingleOrDefault()));

            if (user.YetkiId == 1)
            {
                return(RedirectToAction("GetLessons", "Admin"));
            }

            return(RedirectToAction("GetTeacher", new RouteValueDictionary(new { controller = "Account", action = "GetTeacher", guid = user.Guid })));
        }
コード例 #3
0
        public async Task <IHttpActionResult> Delete(Guid id)
        {
            var result = await _lessonService.Delete(id);

            if (!result)
            {
                return(BadRequest());
            }

            return(Ok());
        }
コード例 #4
0
        public IActionResult Delete(int id)
        {
            var entity = _lessonService.GetById(id);

            if (entity != null)
            {
                _lessonService.Delete(entity);
            }

            return(RedirectToAction("LessonList"));
        }
コード例 #5
0
        private void btnDeleteLesson_Click(object sender, EventArgs e)
        {
            int lessonId = (int)dgwLessons.CurrentRow.Cells["Id"].Value;

            Lesson currentLesson = _lessonService.GetAll().SingleOrDefault(p => p.Id == lessonId);

            if (currentLesson != null)
            {
                _lessonService.Delete(currentLesson);
                LoadLessons();
            }
        }
コード例 #6
0
 public ActionResult Delete(Lesson lesson)
 {
     try
     {
         lessonService.Delete(lesson.LessonId);
         return(RedirectToAction(nameof(Index)));
     }
     catch (ValidationException ex)
     {
         ModelState.AddModelError("", ex.Message);
         return(View(lesson));
     }
 }
コード例 #7
0
        public IActionResult DeleteLesson(int id)
        {
            Lesson           model         = _lessonService.GetById(id);
            List <Questions> modelQuestion = _questionsService.GetAll().Where(x => x.LessonId == model.Id).ToList();

            foreach (var item in modelQuestion)
            {
                _questionsService.Delete(item);
            }
            ;
            _lessonService.Delete(model);
            return(RedirectToAction("ListLesson"));
        }
コード例 #8
0
ファイル: LessonController.cs プロジェクト: bakster55/TPClone
        public ActionResult Delete(Lesson lesson, string courseId)
        {
            try
            {
                _lessonRepository.Delete(lesson.Id);

                return(RedirectToAction("Index", new { courseId = courseId }));
            }
            catch
            {
                return(View(lesson));
            }
        }
コード例 #9
0
        private void buttonDeleteLesson_Click(object sender, RoutedEventArgs e)
        {
            object item = dataGridLesson.SelectedItem;

            if (item == null)
            {
                MessageBox.Show("Please choice data want to delete!");
            }
            else
            {
                _lessonService.Delete(Convert.ToInt16(textBlockIdLesson.Text));
                LoadGridLesson();
            }
        }
コード例 #10
0
        public IActionResult Delete(int id)
        {
            if (GetUserId() != id)
            {
                return(Unauthorized());
            }

            try
            {
                _lessonService.Delete(id);
                return(Ok());
            }
            catch (AppException ex)
            {
                return(BadRequest(new { message = ex.Message }));
            }
        }
コード例 #11
0
        // DELETE: api/Lessons/5
        public HttpResponseMessage DeleteLesson(int id)
        {
            var message = Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Bad Request");

            if (string.IsNullOrWhiteSpace(id.ToString()))
            {
                message = Request.CreateErrorResponse(HttpStatusCode.NotFound, "Invalid Id");
            }
            else
            {
                var result = _iLessonService.Delete(id);
                if (result)
                {
                    message = Request.CreateResponse(HttpStatusCode.OK);
                }
            }
            return(message);
        }
コード例 #12
0
        public async Task <IActionResult> Delete(int id)
        {
            Lesson lesson = await _lessonService.GetById(id);

            if (lesson == null)
            {
                return(NotFound());
            }

            try
            {
                await _lessonService.Delete(lesson);

                return(Ok("Ders Başarıyla Silindi"));
            }
            catch
            {
                return(BadRequest("Ders Silme İşlemi Başarısız"));
            }
        }
コード例 #13
0
        public IActionResult DeleteLesson(int Id)
        {
            try

            {
                var result = _LessonService.Delete(Id);

                if (result.IsSucceeded)
                {
                    return(Ok(result.Result));
                }
                return(BadRequest(result.HttpGetResponse()));
                //return result.HttpGetResponse();
            }
            catch (Exception e)

            {
                return(BadRequest(e.Message));
            }
        }
コード例 #14
0
        public IActionResult Delete(Guid guid)
        {
            var user = _kullaniciService.GetByGuid(guid);

            if (user == null)
            {
                return(View("Error"));
            }
            _kullaniciService.Delete(user.Id);

            var teacherLesson = _tutorLessonService.GetByLessons(guid);

            if (teacherLesson != null)
            {
                foreach (var item in teacherLesson)
                {
                    _tutorLessonService.Delete(item.Id);
                    _lessonService.Delete(item.LessonId);
                }
            }

            return(RedirectToAction("GetTeachers", "Admin"));
        }
コード例 #15
0
        public async Task <ActionResult <Lesson> > Delete(Guid id)
        {
            var currentUser   = HttpContext.GetUser();
            var currentLesson = await _lessons.Get(id, HttpContext.RequestAborted);

            if (currentLesson == null)
            {
                return(NotFound());
            }

            if (!await _authorization.HasAuthorship(currentUser, currentLesson, HttpContext.RequestAborted))
            {
                return(Unauthorized());
            }

            var result = await _lessons.Delete(id, HttpContext.RequestAborted);

            if (!result)
            {
                return(StatusCode(500, new ErrorResponse("An internal error occured while trying to delete this entity. Please contact an administrator if this is not intended.")));
            }

            return(currentLesson);
        }
コード例 #16
0
 public ActionResult <LessonBO> Delete(int id)
 {
     return(Ok(_lessonService.Delete(id)));
 }
コード例 #17
0
 // DELETE: api/Lesson/5
 public void Delete(int id)
 {
     _lessonService.Delete(id);
 }
コード例 #18
0
 public JsonResult DeleteLesson(int id)
 {
     return(Json(_lessonService.Delete(id)));
 }
コード例 #19
0
 public IActionResult DeleteConfirmed(Guid id)
 {
     _lessonService.Delete(id);
     return(RedirectToAction(nameof(Index)));
 }