Esempio n. 1
0
        public JsonResult Deletar(int id)
        {
            try
            {
                var celula = _svcCelula.GetById(id);

                if (celula == null)
                {
                    throw new HttpException(404, "Celula não encontrada");
                }

                _svcCelula.Remove(celula);

                return(Json("OK"));
            }
            catch (Exception ex)
            {
                throw new HttpException(500, $"Erro ao executar o comando no servidor. o erro foi: {ex.Message}");
            }
        }
Esempio n. 2
0
        public async Task <IHttpActionResult> DeleteConfirmed(int id)
        {
            if (ModelState.IsValid)
            {
                var _celula = await Task.FromResult(_celulaApp.GetById(id));

                if (_celula == null)
                {
                    return(NotFound());
                }
                else
                {
                    _celulaApp.Remove(_celula);
                    return(Ok());
                }
            }
            else
            {
                return(BadRequest());
            }
        }