Example #1
0
        public IActionResult Insert(
            [FromBody] NaturezaInsertCommand command,
            [FromServices] NaturezaService service
            )
        {
            GenericResult result = service.Exec(command);

            return(StatusCode(result.Status, result));
        }
Example #2
0
        public IActionResult Update(
            [FromBody] NaturezaUpdateCommand command,
            [FromServices] NaturezaService service,
            [FromServices] IMemoryCache cache
            )
        {
            GenericResult result = service.Exec(command);

            if (result.Status == 200)
            {
                cache.Remove(command.Id);
            }

            return(StatusCode(result.Status, result));
        }
Example #3
0
        public IActionResult Delete(
            int id,
            [FromServices] NaturezaService service,
            [FromServices] IMemoryCache cache
            )
        {
            NaturezaDeleteCommand command = new NaturezaDeleteCommand(id);

            GenericResult result = service.Exec(command);

            if (result.Status == 204)
            {
                cache.Remove(id);
            }

            return(StatusCode(result.Status, result));
        }