public HttpResponseMessage Delete(Student e) { var students = StudentsRepository.DeleteStudent(e); HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.OK, students); return(response); }
private void DeleteStudent(StudentsViewModel student) { Students.Remove(student); _repo.DeleteStudent(new Student(student.Id, student.LastName, student.FirstName, student.Age, student.Gender)); Students.Clear(); ReadStudentsClick(); }
public ActionResult Delete(int id, Student student) { try { // TODO: Add delete logic here StudentsRepository.DeleteStudent(id); return(RedirectToAction(nameof(Index))); } catch { return(View()); } }
public async Task <IActionResult> DeleteStudent(string ritmLogin) { try { await _studentsRepository.DeleteStudent(ritmLogin); return(OkJson <object>()); } catch (Exception e) { throw new Exception($"Couldn't delete student {ritmLogin}", e); } }
/// <summary> /// Przycisk usuwający studenta o zadanym indeksie /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonDeleteStudent_Click(object sender, EventArgs e) { GetDataFromTextBoxes(); try { studentsRepository.DeleteStudent(index); } catch (Exception) { MessageBox.Show("Podany indeks nie istnieje"); } RefreshDataGridView(); }
public ActionResult Delete(int id) { try { StudentsRepository.DeleteStudent(id, this.CurrentUser.Class_id); TempData["success"] = "1"; } catch (Exception ex) { //Log to the database TempData["success"] = "0"; } return(RedirectToAction("Show")); }
//provides error checking //Chekcs to see if the student with that id exists public async Task <bool> DeleteStudentAsync(string studentId) { //Firstordefaultasync //returns first student it finds with that id or null //letter is the student object. var student = await studentsRepository.Students.FirstOrDefaultAsync(s => s.StudentId == studentId); if (student is null) { //returns a bad request return(false); } studentsRepository.DeleteStudent(student); await studentsRepository.TryAndSaveChangesAsync(); //returns ok if true return(true); }
/// <summary> /// Przycisk usuwający studenta o zadanym indeksie /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonDeleteStudent_Click(object sender, EventArgs e) { GetDataFromTextBoxes(); try { if (studentsRepository.DeleteStudent(index)) { labelOperationStatus.Text = "USUNIĘTO STUDENTA O INDEKSIE " + index; } else { labelOperationStatus.Text = "BŁĄD PRZY USUWANIU STUDENTA O INDEKSIE " + index; } } catch (Exception) { labelOperationStatus.Text = "BŁĄD PRZY USUWANIU STUDENTA O INDEKSIE " + index; MessageBox.Show("Podany indeks nie istnieje"); } RefreshDataGridView(); }
public ActionResult Delete(StudentsModel model) { repository.DeleteStudent(model.StudentNo); return(RedirectToAction("GetAllStudents")); }