public async Task <ActionResult> Delete(int?id)
        {
            var instructorService = new InstructorService(new InstructorRepository(UniversityContext));
            await instructorService.Delete(id.Value);

            return(RedirectToAction("Index", "Instructors"));
        }
示例#2
0
        public async Task <IHttpActionResult> Delete(int id)//se devuelve un DTO
        {
            var flag = await instructorService.GetById(id);

            if (flag == null)
            {
                return(NotFound());
            }
            try
            {
                //si el objeto no esta relacionado en otra entidad, lo puede eliminar.
                if (!await instructorService.DeleteCheckOnEntity(id))
                {
                    await instructorService.Delete(id);

                    return(Ok());
                }
                else
                {
                    throw new Exception("No se puede eliminar el objeto, esta relacionado en otra entidad.");
                }
            }
            catch (Exception ex)
            {
                return(InternalServerError(ex));
            }
        }
示例#3
0
        public async Task <ActionResult> Delete(int id)
        {
            try
            {
                await _instructorService.Delete(id);

                return(RedirectToAction("Index"));
            }
            catch (RetryLimitExceededException)
            {
                ModelState.AddModelError("", "Unable to save changes. Try again, and if the problem persists, see your system administrator.");
            }
            var instructor = await _instructorService.Get(id);

            return(View(instructor));
        }
示例#4
0
        public async Task <IHttpActionResult> Delete(int id)
        {
            var flag = await instructorService.GetById(id);

            if (flag == null)
            {
                return(NotFound());//status code 404
            }
            try
            {
                await instructorService.Delete(id);

                return(Ok());//status code 200
            }
            catch (Exception ex)
            {
                return(InternalServerError(ex));//status code 500
            }
        }
示例#5
0
        public async Task <IHttpActionResult> Delete(int id)
        {
            var flag = await instructorService.GetById(id);

            if (flag == null)
            {
                return(NotFound()); // status code 404
            }
            try
            {
                //if (!await courseService.DeleteCheckOnEntity(id))
                await instructorService.Delete(id);

                //else
                // throw new Exception("ForengKeys");

                return(Ok()); //Sastus code 200
            }
            catch (Exception ex)
            {
                return(InternalServerError(ex)); //Status code 500
            }
        }
        public async Task <IHttpActionResult> Delete(int id)
        {
            var flag = await instructorService.GetById(id);

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

            try
            {
                if (!await instructorService.DeleteCheckOnEntity(id))
                {
                    await instructorService.Delete(id);
                }
                else
                {
                    throw new Exception("ForeignKeys");
                }

                return(Ok());
            }
            catch (Exception ex) { return(InternalServerError(ex)); }
        }
示例#7
0
        public async Task <IActionResult> Delete(int id)
        {
            await _service.Delete(id);

            return(Ok());
        }