コード例 #1
0
        public async Task <NotificationResultDto> Handle(CreateBroadcastersCommand command, CancellationToken cancellationToken)
        {
            try
            {
                if (!command.Valid())
                {
                    return(_handlerResponse.Response(command.IsValid, command.Notifications));
                }

                var broadcasterEntities = await _broadcastersRepository.GetByNameAsync(command.BrodcastersName);

                var broadcaster = new Broadcasters(command.BrodcastersName);

                if (broadcasterEntities != null)
                {
                    broadcaster.NameUnavailable();
                }

                if (broadcaster.IsValid)
                {
                    await _broadcastersRepository.InsertAsync(broadcaster);
                }

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

            return(_handlerResponse.Response(IsValid, Notifications));
        }
コード例 #2
0
        public async Task <IActionResult> Post([FromBody] CreateBroadcastersCommand command)
        {
            var notificationResult = await _broadcastersAppService.CreateAsync(command);

            return(Response(notificationResult));
        }
コード例 #3
0
 public async Task <NotificationResultDto> CreateAsync(CreateBroadcastersCommand command)
 => await _mediator.Send(command);