Ejemplo n.º 1
0
        public HttpResponseMessage Delete(Student e)
        {
            var students = StudentsRepository.DeleteStudent(e);
            HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.OK, students);

            return(response);
        }
Ejemplo n.º 2
0
 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());
     }
 }
Ejemplo n.º 4
0
        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);
            }
        }
Ejemplo n.º 5
0
 /// <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();
 }
Ejemplo n.º 6
0
 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"));
 }
Ejemplo n.º 7
0
        //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);
        }
Ejemplo n.º 8
0
 /// <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();
 }
Ejemplo n.º 9
0
 public ActionResult Delete(StudentsModel model)
 {
     repository.DeleteStudent(model.StudentNo);
     return(RedirectToAction("GetAllStudents"));
 }