public async Task <IActionResult> GetAll([FromQuery] int?limit, [FromQuery] int?days,
                                                 [FromQuery] string startingDate, [FromQuery] string endingDate, [FromQuery] string status,
                                                 [FromQuery] string category, [FromQuery] string orderBy, [FromQuery] string orderField)
        {
            var response = await _mediator.Send(new ListEventCommand()
            {
                Limit        = limit,
                Days         = days,
                StartingDate = startingDate,
                EndingDate   = endingDate,
                Status       = status,
                Category     = category,
                OrderBy      = orderBy,
                OrderField   = orderField
            });

            if (_notificationContext.HasErrorNotifications)
            {
                var notifications = _notificationContext.GetErrorNotifications();
                var message       = string.Join(", ", notifications.Select(x => x.Value));
                return(BadRequest(message));
            }

            return(Ok(response));
        }
        public async Task <IActionResult> GetByCode([FromRoute] int id)
        {
            var response = await _mediator.Send(new GetTariffByIdEvent()
            {
                Id = id
            });

            if (_notificationContext.HasErrorNotifications)
            {
                var notifications = _notificationContext.GetErrorNotifications();
                var message       = string.Join(", ", notifications.Select(x => x.Value));
                return(BadRequest(message));
            }

            return(Ok(response));
        }
Пример #3
0
        public async Task <IActionResult> GetAll()
        {
            var response = await _mediator.Send(new ListCategoryCommand()
            {
            });

            if (_notificationContext.HasErrorNotifications)
            {
                var notifications = _notificationContext.GetErrorNotifications();
                var message       = string.Join(", ", notifications.Select(x => x.Value));
                return(BadRequest(message));
            }

            return(Ok(response));
        }