예제 #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));
        }
        public async Task <IActionResult> Post([FromBody] CreateBroadcastersCommand command)
        {
            var notificationResult = await _broadcastersAppService.CreateAsync(command);

            return(Response(notificationResult));
        }
 public async Task <NotificationResultDto> CreateAsync(CreateBroadcastersCommand command)
 => await _mediator.Send(command);