Пример #1
0
        public async Task <IActionResult> Delete(int id)
        {
            if (ModelState.IsValid)
            {
                // Todo is ok
                _message = await Task.Run(() => _student.Delete(id));

                if (_message.status_item)
                {
                    return(Ok(_message.details));
                }
                else
                {
                    return(StatusCode(401, _message.Res()));
                }
            }
            else
            {
                var mes = string.Join(" | ", ModelState.Values
                                      .SelectMany(v => v.Errors)
                                      .Select(e => e.ErrorMessage));

                _message.details = mes;
                return(BadRequest(_message.Res()));
            }
        }
Пример #2
0
        public ActionResult Delete(int id)
        {
            string msg;
            bool   hasError = student.Delete(id, out msg);

            return(Json(new { Error = hasError, Message = msg }, JsonRequestBehavior.AllowGet));
        }
Пример #3
0
        private void dataGridView1_CellContentClick_1(object sender, DataGridViewCellEventArgs e)
        {
            var index = e.RowIndex; var dg = sender;
            var ci = e.ColumnIndex;

            if (e.RowIndex >= 0)
            {
                if (e.ColumnIndex == 10)
                {
                    var dresult = MessageBox.Show("Are you Sure to delete Student", "Delete", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1);
                    if (DialogResult.Yes == dresult)
                    {
                        DataGridViewRow row = this.dataGridView1.Rows[e.RowIndex];
                        if (DialogResult.OK == MessageBox.Show("record deleted", "Deleted", MessageBoxButtons.OK, MessageBoxIcon.Information))
                        {
                            _StudentRepo.Delete(Convert.ToInt32(row.Cells[0].Value));
                            RefreshStudentTable();
                        }
                    }
                    else
                    {
                        MessageBox.Show("Student Record Is Safe", "Safe", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
                else
                {
                    //gets a collection that contains all the rows
                    DataGridViewRow row       = this.dataGridView1.Rows[e.RowIndex];
                    var             studentid = Convert.ToInt32(row.Cells[0].Value);
                    EditStudent     f         = new EditStudent(Kernal, studentid, USER_ID, this);
                    f.UpdateEventHandler += f2_UpdateStudentGridHandler;
                    f.ShowDialog();
                }
            }
        }
Пример #4
0
        public IActionResult Delete(int aStudentId)
        {
            Student myStudent = _repo.Delete(aStudentId);

            if (myStudent != null)
            {
                var myResponse = _mapper.Map <StudentDtoRead>(myStudent);
                return(Ok(myResponse));
            }
            return(NotFound());
        }
Пример #5
0
        private void BtnDelete_Click(object sender, EventArgs e)
        {
            var x = MessageBox.Show("Are you Sure to delete Student", "caption", MessageBoxButtons.YesNo, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);

            if (DialogResult.Yes == x)
            {
                _StudentRepo.Delete(StudentId);
                RefreshStudentGridView();
                this.Close();
            }
        }
 public bool Delete(int Id)
 {
     if (student.Any(s => s.StudentId == Id))
     {
         student.Delete(student.GetById(Id));
         return(true);
     }
     else
     {
         return(false);
     }
 }
        public async Task <ActionResult> Delete(string id)
        {
            try
            {
                await _student.Delete(id);

                return(RedirectToAction(nameof(Index)));
            }
            catch
            {
                return(View());
            }
        }
Пример #8
0
        public IActionResult DeleteStudent(int id)
        {
            var cinema = _student.GetById(id);

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

            _student.Delete(cinema);

            return(NoContent());
        }
        public async Task <IActionResult> Delete(int id)
        {
            try
            {
                await _student.Delete(id);

                return(Ok("Data berhasil didelete"));
            }
            catch (Exception ex)
            {
                return(BadRequest($"Data gagal didelete {ex.Message}"));
            }
        }
        public async Task <ActionResult> DeletePost(int id)
        {
            try
            {
                await _student.Delete(id.ToString());

                TempData["pesan"] = $"Data student berhasil didelete";
                return(RedirectToAction(nameof(Index)));
            }
            catch (Exception ex)
            {
                ViewBag.Pesan = $"Error: {ex.Message}";
                return(View());
            }
        }
        public async Task <ActionResult <Student> > DeleteStudent(int id)
        {
            var student = await Task.Run(() => _studentrepo.Delete(id));

            //   var student = await _context.Students.FindAsync(id);
            //if (student == null)
            //{
            //    return NotFound();
            //}

            //_context.Students.Remove(student);
            //await _context.SaveChangesAsync();

            return(student);
        }
Пример #12
0
 public MessageModel <Student> Delete(long id)
 {
     if (IStudent.Delete(id))
     {
         return(new MessageModel <Student> {
             Success = true, Msg = "操作成功"
         });
     }
     else
     {
         return(new MessageModel <Student> {
             Success = false, Msg = "操作失败"
         });
     }
 }
Пример #13
0
 private void buttonDel_Click_1(object sender, EventArgs e)
 {
     if (dataGridView.SelectedRows.Count == 1)
     {
         if (MessageBox.Show("Удалить запись", "Вопрос", MessageBoxButtons.YesNo,
                             MessageBoxIcon.Question) == DialogResult.Yes)
         {
             int id =
                 Convert.ToInt32(dataGridView.SelectedRows[0].Cells[0].Value);
             try
             {
                 logic.Delete(new StudentBM {
                     Id = id
                 });
             }
             catch (Exception ex)
             {
                 MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
                                 MessageBoxIcon.Error);
             }
             LoadData();
         }
     }
 }
Пример #14
0
 public IHttpActionResult Delete(int id)
 {
     _repo.Delete(id);
     return(Ok(true));
 }
Пример #15
0
 /// <summary>
 /// 删除一条数据
 /// </summary>
 public bool Delete(int id)
 {
     return(dal.Delete(id));
 }
        public async Task <ActionResult <StudentModel> > DeleteStudent(int id)
        {
            var deleted = await _student.Delete(id);

            return(responseByEntityResult(deleted));
        }
Пример #17
0
 public void Delete(Student student)
 {
     studentRepository.Delete(student);
 }
Пример #18
0
        public IActionResult Delete(int ID)
        {
            var stud = _student.Delete(ID);

            return(View("Deleted", stud));
        }
Пример #19
0
 public IActionResult Delete(int id)
 {
     _db.Delete(id);
     return(RedirectToAction("Index"));
 }
Пример #20
0
 public IActionResult DeleteConfirm(Student stud, long Id)
 {
     _student.Delete(Id);
     return(View("Success"));
 }
Пример #21
0
 public bool Delete(string ID)
 {
     return(dal.Delete(ID));
 }
        public async Task <ActionResult> DeleteStudent(int id)
        {
            await _student.Delete(id);

            return(NoContent());
        }
Пример #23
0
 public IActionResult Delete(int id)
 {
     _studentRepo.Delete(id);
     return(RedirectToAction("index"));
 }