Exemplo n.º 1
0
        public async Task <ActionResult> Delete(int id, IFormCollection collection)
        {
            if (id == 0)
            {
                return(NotFound());
            }

            var entity = await _postoSaudeService.GetByIdAsync(id);

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

            try
            {
                await _postoSaudeService.DisableAsync(entity);

                return(RedirectToAction(nameof(Index)));
            }
            catch (Exception)
            {
                return(BadRequest(
                           new
                {
                    Error = "Ocorreu um erro para salvar os dados. Tente novamente mais tarde! Se o problema persistir entre em contato com o suporte técnico."
                }
                           ));
            }
        }
Exemplo n.º 2
0
        public async Task <ActionResult> Disable(long id)
        {
            var entity = await _postoSaudeService.GetByIdAsync(id);

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

            try
            {
                await _postoSaudeService.DisableAsync(entity);
            }
            catch (Exception)
            {
                return(BadRequest(
                           new
                {
                    Error = "Ocorreu um erro para salvar os dados. Tente novamente mais tarde! Se o problema persistir entre em contato com o suporte técnico."
                }
                           ));
            }

            return(Ok());
        }