Пример #1
0
        public async Task <HttpResult <ToggleMessageResponse> > Delete(int id)
        {
            var retorno = new HttpResult <ToggleMessageResponse>();

            if (id <= 0)
            {
                return(retorno.SetToUnprocessableEntity(ServiceConstants.IDENTIFICADOR_INVALIDO));
            }

            var retornoTaskDelete = ToggleServiceTask.Delete(id);

            retorno.Response = MapToResponseToggleMessage.MapToToggleMessageResponse(retornoTaskDelete.Result.Response);
            retorno.Message  = retornoTaskDelete.Result.Message;

            return(retorno);
        }
Пример #2
0
        public async Task <HttpResult <ToggleMessageResponse> > Create(ToggleCreateMessageRequest request)
        {
            var retorno = new HttpResult <ToggleMessageResponse>();

            if (request == null)
            {
                return(retorno.SetHttpStatusToBadRequest());
            }

            var retornoTaskCreate = ToggleServiceTask.Create(MapToModelToggle.MapToModel(request), request.IdsServiceRota);

            retorno.Response = MapToResponseToggleMessage.MapToToggleMessageResponse(retornoTaskCreate.Response);
            retorno.Message  = retornoTaskCreate.Message;

            return(retorno);
        }
Пример #3
0
        public async Task <HttpResult <ToggleMessageResponse> > Update(int id, ToggleUpdateMessageRequest request)
        {
            var retorno = new HttpResult <ToggleMessageResponse>();

            if (id <= 0)
            {
                return(retorno.SetToUnprocessableEntity(ServiceConstants.IDENTIFICADOR_INVALIDO));
            }
            if (request == null)
            {
                return(retorno.SetHttpStatusToBadRequest());
            }

            var retornoTaskUpdate = ToggleServiceTask.Update(id, request.Description, request.Flag, request.IdsServiceRota);

            retorno.Response = MapToResponseToggleMessage.MapToToggleMessageResponse(retornoTaskUpdate.Result.Response);
            retorno.Message  = retornoTaskUpdate.Result.Message;

            return(retorno);
        }