Exemple #1
0
        public IHttpActionResult Delete(Subject id)
        {
            bool deleted = subRepo.Delete(id.ID);

            if (!deleted)
            {
                return(BadRequest());
            }
            return(Ok());
        }
Exemple #2
0
        private void subjectDeleteButton_Click(object sender, EventArgs e)
        {
            var selectedRowIndex = GetSelectedRowIndex(subjectDataGridView);

            if (selectedRowIndex == null)
            {
                return;
            }
            SubjectsRepository.Delete(SubjectsRepository.GetAll()[(int)selectedRowIndex].Id);
            UpdateSubjectsGrid();
        }
 public ActionResult Delete(int id, FormCollection collection)
 {
     try
     {
         bool success = sRepo.Delete(id);
         if (success)
         {
             return(RedirectToAction("Index"));
         }
         ViewBag.EMessage = "Error 666: The subject you want to delete can't be deleted. (Make sure that course(s) are removed.)";
         return(View());
     }
     catch
     {
         return(View());
     }
 }
Exemple #4
0
        public async Task <IActionResult> Delete(int id)
        {
            try
            {
                var entity = await _subjectsRepository.Read(id).ConfigureAwait(false);

                if (entity == null)
                {
                    return(HttpBadRequest($"There is no student with {id} id"));
                }

                await _subjectsRepository.Delete(entity).ConfigureAwait(false);

                return(Ok());
            }
            catch (Exception exception)
            {
                return(HttpNotFound(exception));
            }
        }