コード例 #1
0
        public void Service_Deve_Excluir_Motorista()
        {
            int motoristaId = 1;

            _service.Delete(motoristaId);
            _repMotoristaMock.Verify(x => x.Delete(It.IsAny <int>()), Times.Once);
            var motoristas = _service.GetAll().Result;

            Assert.True(0 == motoristas.Count());
        }
コード例 #2
0
        public IActionResult Delete(int id)
        {
            var motorista = _motoristaService.Obter(id);

            if (motorista == null)
            {
                return(StatusCode(404, "Motorista não encontrado"));
            }

            _motoristaService.Delete(id);

            return(Ok("deleted"));
        }
コード例 #3
0
        public async Task <IActionResult> Delete(int id)
        {
            string sessionId = Guid.NewGuid().ToString();

            try
            {
                _logger.LogInformation("[{0}][INFO]Wappa.Api.Controllers.MotoristaController.Delete({1})"
                                       , sessionId, id);

                var result = await _service.Delete(id);

                _logger.LogInformation("[{0}][INFO]Wappa.Api.Controllers.MotoristaController.Delete({1}) {2}"
                                       , sessionId, id, JsonConvert.SerializeObject(result));

                return(NoContent());
            }
            catch (Exception ex)
            {
                _logger.LogError("[{0}][ERROR]Wappa.Api.Controllers.MotoristaController.Delete({1}) {2}"
                                 , sessionId, id, ex.Message);
                return(BadRequest(ex.Message));
            }
        }