Esempio n. 1
0
        public async Task SendRegionSubscriptionConformationMailAsync(string region, RegionSubscription regionSubscription)
        {
            await Task.Run(async() =>
            {
                var subject = ConstructSubjectText(region, "Danke für Ihr Interesse",
                                                   "Thank you for your interest");

                var germanText  = $@"Liebe/r {regionSubscription.name},

vielen Dank für Ihr Interesse an PIRAT. Sie werden von nun an über neue Angebote in der Nähe von {regionSubscription.postal_code} benachrichtigt.

Falls Sie die Benachrichtigung beenden wollen oder noch Fragen zu PIRAT haben, melden Sie sich gerne jederzeit unter [email protected].


Beste Grüße,
Ihr PIRAT-Team";
                var englishText = $@"Dear {regionSubscription.name},

Thank you very much for your interest in PIRAT. You will now get notifications about new offers in the region {regionSubscription.postal_code}.

If you wish to cancel the subscription or have any questions regarding PIRAT, please contact us at [email protected].


Best regards,
your PIRAT-Team";
                var content     = ConstructEmailText(region, germanText, englishText);
                await SendMailAsync(regionSubscription.email, subject, content);
            });
        }
Esempio n. 2
0
        public async Task SubscribeRegionAsync(RegionSubscription subscription, string region)
        {
            NullCheck.ThrowIfNull <RegionSubscription>(subscription);
            AddressEntity addressEntity = new AddressEntity()
            {
                PostalCode = subscription.postal_code,
                Country    = "Deutschland"
            };

            _addressMaker.SetCoordinates(addressEntity);
            subscription.latitude  = addressEntity.Latitude;
            subscription.longitude = addressEntity.Longitude;
            subscription.active    = true;
            subscription.region    = region;
            await subscription.InsertAsync(_context);
        }
Esempio n. 3
0
        public IActionResult Post([FromQuery][Required] string region, [FromBody] RegionSubscription regionsubscription)
        {
            NullCheck.ThrowIfNull <RegionSubscription>(regionsubscription);

            try
            {
                _configurationService.ThrowIfUnknownRegion(region);
                _mailInputValidatorService.validateMail(regionsubscription.email);
                this._subscriptionService.SubscribeRegionAsync(regionsubscription, region);
                this._mailService.SendRegionSubscriptionConformationMailAsync(region, regionsubscription);
            }
            catch (ArgumentException e)
            {
                return(BadRequest(e.Message));
            }
            catch (UnknownAdressException e)
            {
                return(BadRequest(e.Message));
            }
            return(Ok());
        }
Esempio n. 4
0
        public async Task SendNotificationAboutNewOffersAsync(string region, RegionSubscription regionSubscription,
                                                              ResourceCompilation resourceCompilation)
        {
            string offersDE = SummarizeResourcesToFormattedString(resourceCompilation, "de");
            string offersEN = SummarizeResourcesToFormattedString(resourceCompilation, "en");

            await Task.Run(async() =>
            {
                var subject = ConstructSubjectText(region, "Neue Angebote", "New Offers");

                var germanText  = $@"Liebe/r {regionSubscription.name},

wir haben neue Angebote für Sie auf PIRAT in der Nähe von {regionSubscription.postal_code}. Sie können sie unter https://pirat-tool.com/{region}/de/suchanfrage finden.

{offersDE}

Falls Sie die Benachrichtigung beenden wollen oder noch Fragen zu PIRAT haben, melden Sie sich gerne jederzeit unter [email protected].


Beste Grüße,
Ihr PIRAT-Team";
                var englishText = $@"Dear {regionSubscription.name},

There are new offers on PIRAT for you in the region {regionSubscription.postal_code}. You can find them under https://pirat-tool.com/{region}/en/suchanfrage.

{offersEN}

If you wish to cancel the subscription or have any questions regarding PIRAT, please contact us at [email protected].


Best regards,
your PIRAT-Team";
                var content     = ConstructEmailText(region, germanText, englishText);
                await SendMailAsync(regionSubscription.email, subject, content);
            });
        }