コード例 #1
0
        public IActionResult DeletePoi(int cityId, int id)
        {
            if (!mCityRepo.DoesCityExist(cityId))
            {
                return(NotFound(new { CityId = cityId }));
            }

            var existingPoi = mCityRepo.GetPoi(cityId, id);

            if (existingPoi == null)
            {
                return(NotFound(new { PoiId = id }));
            }

            mCityRepo.DeletePoi(existingPoi);

            if (!mCityRepo.Save())
            {
                return(StatusCode(500, "Problem occured while saving to the database."));
            }

            mSender.Send("POI deleted", $"POI {existingPoi.Id} '{existingPoi.Name}' was deleted.");

            return(NoContent());
        }
コード例 #2
0
        public Task Handle(AddVehicleEvent notification, CancellationToken cancellationToken)
        {
            Vehicle vehicle = notification.Vehicle;

            senderService.Send($"Vehicle {vehicle.Name} was added");

            return(Task.CompletedTask);
        }
コード例 #3
0
        public async Task InvokeAsync(HttpContext context)
        {
            Trace.WriteLine($"request {context.Request.Method} {context.Request.Path}");
            senderService.Send(context.Request.Path);

            await next.Invoke(context);

            Trace.WriteLine($"response {context.Response.StatusCode}");
        }
コード例 #4
0
        public async Task <ActionResult <IEnumerable <Customer> > > Get([FromServices] ISenderService senderService)
        {
            var customers = await customerService.GetAsync().ConfigureAwait(false);

            ISenderService sender = this.HttpContext.RequestServices.GetService(typeof(ISenderService)) as ISenderService;

            senderService.Send($"Pobrano {customers.Count()} klientów");

            return(Ok(customers));
        }
コード例 #5
0
ファイル: EmailServiceSenderTests.cs プロジェクト: radtek/Hey
        public void TestSmtpClient()
        {
            SendEmailClient emailClient   = new SendEmailClient(_hostname, _hostport, _username, _password, _security);
            ISenderService  senderService = emailClient.ComposeMessage(_from);

            Mock <IMessageProvider> messageProvideMock = new Mock <IMessageProvider>();

            messageProvideMock.Setup(provider => provider.GetText()).Returns("Test text");
            messageProvideMock.Setup(provider => provider.GetAbstract()).Returns("Test subject");

            Assert.DoesNotThrow(() => senderService.Send(messageProvideMock.Object, _to));
        }
コード例 #6
0
        public async Task <bool> Handle(SenderCommand request, CancellationToken cancellationToken)
        {
            _logger.LogInformation($"Отправка данных [{request.User}]...");
            bool result = await _dataBusSenderService.Send(request.User, cancellationToken);

            if (result)
            {
                _logger.LogInformation("Отправка данных завершилась успешно");
            }
            else
            {
                _logger.LogInformation("Ошибка отправки данных");
            }

            return(result);
        }
コード例 #7
0
        public Task Handle(AddCustomerEvent notification, CancellationToken cancellationToken)
        {
            senderService.Send(notification.Customer);

            return(Task.CompletedTask);
        }
コード例 #8
0
 public void Send(string receiverString)
 {
     _senderService.Send(_messageProvider, receiverString);
 }