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); } }
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 }))); }
public async Task <IHttpActionResult> Delete(Guid id) { var result = await _lessonService.Delete(id); if (!result) { return(BadRequest()); } return(Ok()); }
public IActionResult Delete(int id) { var entity = _lessonService.GetById(id); if (entity != null) { _lessonService.Delete(entity); } return(RedirectToAction("LessonList")); }
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(); } }
public ActionResult Delete(Lesson lesson) { try { lessonService.Delete(lesson.LessonId); return(RedirectToAction(nameof(Index))); } catch (ValidationException ex) { ModelState.AddModelError("", ex.Message); return(View(lesson)); } }
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")); }
public ActionResult Delete(Lesson lesson, string courseId) { try { _lessonRepository.Delete(lesson.Id); return(RedirectToAction("Index", new { courseId = courseId })); } catch { return(View(lesson)); } }
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(); } }
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 })); } }
// 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); }
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")); } }
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)); } }
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")); }
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); }
public ActionResult <LessonBO> Delete(int id) { return(Ok(_lessonService.Delete(id))); }
// DELETE: api/Lesson/5 public void Delete(int id) { _lessonService.Delete(id); }
public JsonResult DeleteLesson(int id) { return(Json(_lessonService.Delete(id))); }
public IActionResult DeleteConfirmed(Guid id) { _lessonService.Delete(id); return(RedirectToAction(nameof(Index))); }