Ejemplo n.º 1
0
        // POST: Doctors/Delete/5
        public async Task <IActionResult> Delete(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            try
            {
                await _doctorRepository.DeleteDoctorAsync(id.Value);
            }
            //catch (DbUpdateException dbUpdateException)
            //{
            //    if (dbUpdateException.InnerException.Message.Contains("REFERENCE"))
            //    {
            //        ModelState.AddModelError(string.Empty, "This record have appointments.");
            //    }
            //    else
            //    {
            //        ModelState.AddModelError(string.Empty, dbUpdateException.InnerException.Message);
            //    }
            //}
            catch (Exception exception)
            {
                ModelState.AddModelError(string.Empty, exception.Message);
            }

            return(RedirectToAction(nameof(Index)));
        }
Ejemplo n.º 2
0
        public async Task <ActionResult> Delete(int id)
        {
            Doctor doctor = await _doctorRepository.DeleteDoctorAsync(id, _env.WebRootPath);

            if (doctor == null)
            {
                return(NotFound());
            }
            return(Ok());
        }
Ejemplo n.º 3
0
        public async Task <ActionResult> Delete(int id)
        {
            try
            {
                await _doctorRepository.DeleteDoctorAsync(id);

                AddMessage("Doctor Delete Success", true);
            }
            catch (Exception e)
            {
                AddMessage("Doctor Delete Failed");
            }
            return(RedirectToAction(nameof(Index)));
        }