public async Task <IActionResult> Delete(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            try
            {
                await _serviceTypeRepository.DeleteServiceTypeAsync(id.Value);
            }
            //catch (DbUpdateException dbUpdateException)
            //{
            //    if (dbUpdateException.InnerException.Message.Contains("delete"))
            //    {
            //        ModelState.AddModelError(string.Empty, "This record have doctors.");
            //    }
            //    else
            //    {
            //        ModelState.AddModelError(string.Empty, dbUpdateException.InnerException.Message);
            //    }
            //}
            catch (Exception exception)
            {
                ModelState.AddModelError(string.Empty, exception.Message);
            }

            return(RedirectToAction(nameof(Index)));
        }
Esempio n. 2
0
        public async Task <IActionResult> DeleteServiceType(int id)
        {
            await _repository.DeleteServiceTypeAsync(id);

            return(NoContent());
        }