Example #1
0
 public IActionResult Delete(long id)
 {
     try
     {
         var response = _instructorRepository.Delete(id);
         if (response == "not exists")
         {
             return(NotFound(_NotFound));
         }
         else if (response == "in used")
         {
             return(BadRequest(new GenericResult {
                 Response = false, Message = "Unable to delete. Course Instructor is currently in used."
             }));
         }
         else
         {
             return(Ok(new GenericResult {
                 Response = true, Message = "Course Instructor has been successfully deleted"
             }));
         }
     } catch (Exception e) {
         return(BadRequest(e));
     }
 }
Example #2
0
 public void Delete(int id)
 {
     using (_instructorRepository)
     {
         _instructorRepository.Delete(id);
         _instructorRepository.SaveChanges();
     }
 }
 public ActionResult DeleteConfirmed(int id)
 {
     ViewBag.menu = MENU;
     repository.Delete(id);
     repository.Save();
     TempData["message"] = "Instructor was deleted";
     return(RedirectToAction("Index"));
 }
        private void BtnDelete_Click(object sender, EventArgs e)
        {
            _repository.Delete(txtFirstName.Text.Trim(), txtLastName.Text.Trim());

            SharedViewLogic.LoadInstructors(_dgvInstructors, _repository);

            Close();
        }
        public Instructor Delete(int id)
        {
            Instructor Instructor = IInstructorRepository.Get(id);

            return(IInstructorRepository.Delete(Instructor));

            // trebuie sa sterg si din tabelele de legatura
            // deci facem controllere si pt songAlbum si artitAlbum
        }
Example #6
0
        public async Task <IActionResult> Delete(Instructor instructor)
        {
            if (ModelState.IsValid)
            {
                _instructorRepository.Delete(instructor);
                return(RedirectToAction(nameof(Index)));
            }

            return(View(instructor));
        }
Example #7
0
        public IActionResult DeletePost(int?instructorId)
        {
            var instructor = _instructorRepository.GetById((int)instructorId);

            if (instructor == null && instructorId == null)
            {
                return(NotFound());
            }
            _instructorRepository.Delete(instructor);
            return(RedirectToAction("Index"));
        }
Example #8
0
        public async Task <bool> Handle(DeleteInstructorCommand request, CancellationToken cancellationToken)
        {
            var deleteItem = await _repo.FindAsync(request.InstructorId);

            if (deleteItem == null)
            {
                return(false);
            }
            _repo.Delete(deleteItem);
            return(await _repo.UnitOfWork.SaveEntitiesAsync());
        }
        public async Task <IActionResult> Delete(int id)
        {
            var instructorFromDb = await _instructorRepository.GetInstructor(id);

            if (instructorFromDb == null)
            {
                return(new NotFoundResult());
            }
            await _instructorRepository.Delete(id);

            return(new OkResult());
        }
        public ActionResult DeleteConfirmed(int id)
        {
            Instructor instructor = _instructorRepository.FindById(id);

            instructor.OfficeAssignment = null;
            _instructorRepository.Delete(id);

            var department = _departmentRepository.Get().SingleOrDefault(d => d.InstructorId == id);

            if (department != null)
            {
                department.Instructor = null;
                _departmentRepository.Update(department);
            }

            return(RedirectToAction("Index"));
        }
Example #11
0
        public async Task <Response> Delete(int id)
        {
            try
            {
                Response response = await _InstructorRepo.Delete(id);

                return(response);
            }
            catch (Exception e)
            {
                StringBuilder sb = new StringBuilder();
                log.Error(sb.AppendLine(e.Message).AppendLine(e.StackTrace).ToString());
                Response r = new Response()
                {
                    Success = false
                };
                r.ErrorList.Add("Error on delete Instructor");
                return(r);
            }
        }
        public ActionResult Delete(List <int> ids)
        {
            Dictionary <string, object> res = new Dictionary <string, object>();

            try
            {
                repository.Delete(ids);
                repository.Save();
                res["success"] = 1;
                res["message"] = string.Format("{0} instructor(s) has been successfully deleted", ids.Count);
            }

            catch (Exception ex)
            {
                res["error"]   = 1;
                res["message"] = ex.ToString();
            }

            return(Json(res, JsonRequestBehavior.AllowGet));
        }
Example #13
0
        public IActionResult OnPost(int id)
        {
            //if (ModelState.)
            //{
            //    return RedirectToPage("./Materias");
            //}

            var instructorToDelete = _instructorRepository.GetById(id);

            if (instructorToDelete == null)
            {
                return(NotFound());
            }
            instructorToDelete.Codigo    = Instructor.Codigo;
            instructorToDelete.Nombres   = Instructor.Nombres;
            instructorToDelete.Apellidos = Instructor.Apellidos;
            instructorToDelete.Edad      = Instructor.Edad;
            instructorToDelete.Activo    = Instructor.Activo;

            _instructorRepository.Delete(instructorToDelete);

            return(RedirectToPage("./Instructor"));
        }
 public ActionResult DeleteConfirmed(int id)
 {
     instructorRepository.Delete(id);
     return(RedirectToAction("Index"));
 }
 public void DeleteInstructor(Instructor instructor)
 {
     _repository.Delete(instructor);
 }
Example #16
0
 public void DeleteInstructor(int instructorId)
 {
     _instructorRepository.Delete(instructorId);
     SaveInstructor();
 }