public async Task <NotificationResultDto> Handle(CreateAudienceCommand command, CancellationToken cancellationToken)
        {
            try
            {
                if (!command.Valid())
                {
                    return(_handlerResponse.Response(command.IsValid, command.Notifications));
                }

                var audienteEntites = await _audienceRepository.GetAudienceByBroadcasterAndDateTimeAsync(command.AudienceBroadcaster, command.AudienceDateTime);

                var audience = new Audience(command.AudienceBroadcaster, command.AudienceDateTime, command.AudiencePoints);

                if (audienteEntites != null)
                {
                    audience.AudienceRegister();
                }

                if (audience.IsValid)
                {
                    await _audienceRepository.InsertAsync(audience);
                }

                AddNotifications(audience);
            }
            catch (Exception ex)
            {
                AddNotification("500", ex.Message);
            }

            return(_handlerResponse.Response(IsValid, Notifications));
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> Post([FromBody] CreateAudienceCommand command)
        {
            var notificationResult = await _audienceAppService.CreateAsync(command);

            return(Response(notificationResult));
        }
Ejemplo n.º 3
0
 public async Task <NotificationResultDto> CreateAsync(CreateAudienceCommand command)
 => await _mediator.Send(command);