예제 #1
0
        public async Task<IActionResult> MessageAllVolunteers(MessageEventVolunteersViewModel viewModel)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            var eventsOrganizationId = await _mediator.SendAsync(new OrganizationIdByEventIdQuery { EventId = viewModel.EventId });
            if (!User.IsOrganizationAdmin(eventsOrganizationId))
            {
                return Unauthorized();
            }

            await _mediator.SendAsync(new MessageEventVolunteersCommand { ViewModel = viewModel });

            return Ok();
        }
예제 #2
0
        public async Task<IActionResult> MessageAllVolunteers(MessageEventVolunteersViewModel viewModel)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            //TODO: Query only for the organization Id rather than the whole event detail
            var campaignEvent = await _mediator.SendAsync(new EventDetailQuery { EventId = viewModel.EventId });
            if (campaignEvent == null)
            {
                return NotFound();
            }

            if (!User.IsOrganizationAdmin(campaignEvent.OrganizationId))
            {
                return Unauthorized();
            }

            await _mediator.SendAsync(new MessageEventVolunteersCommand { ViewModel = viewModel });

            return Ok();
        }