예제 #1
0
        public async Task <IActionResult> PersonalAnonymContactAsync([FromBody] ContactInformationDemand contactInformationDemand, int id)
        {
            NullCheck.ThrowIfNull <ContactInformationDemand>(contactInformationDemand);

            try
            {
                _mailInputValidatorService.validateMail(contactInformationDemand.senderEmail);
                var personal = (PersonalEntity)await _resourceStockQueryService.FindAsync(new PersonalEntity(), id);

                if (personal is null)
                {
                    return(NotFound(FailureCodes.NotFoundPersonal));
                }

                var offer = (OfferEntity)await _resourceStockQueryService.FindAsync(new OfferEntity(), personal.offer_id);

                if (offer is null)
                {
                    return(NotFound(FailureCodes.NotFoundOffer));
                }

                var mailAddressReceiver  = offer.mail;
                var mailUserNameReceiver = offer.name;
                await _mailService.SendDemandMailToProviderAsync(offer.region, contactInformationDemand, mailAddressReceiver,
                                                                 mailUserNameReceiver);

                await _mailService.SendDemandConformationMailToDemanderAsync(offer.region, contactInformationDemand);

                return(Ok());
            }
            catch (ArgumentException e)
            {
                return(BadRequest(e.Message));
            }
        }
예제 #2
0
        public async Task SendDemandConformationMailToDemanderAsync(string region, ContactInformationDemand demandInformation)
        {
            await Task.Run(async() =>
            {
                var subject = ConstructSubjectText(region, "Danke für Ihre Anfrage", "Thank you for your request");

                var germanText  = $@"Liebe/r {demandInformation.senderName},

vielen Dank für Ihre Anfrage! Diese wurde an den Anbieter weitergeleitet, der sich in Kürze bei Ihnen melden wird.

PIRAT stellt nur den Kontakt zwischen Anbietern und Suchenden her, alle weiteren Absprachen treffen Sie also bitte direkt mit dem Anbieter.

Vielen Dank, dass Sie unser Angebot genutzt haben. Falls Sie noch Fragen zu PIRAT haben, melden Sie sich gerne jederzeit unter [email protected].

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

Thank you very much for your request! It was forwarded to the provider, who will contact you soon.

PIRAT only offers to bring providers and seekers in contact, please arrange the terms of the exchange directly with the provider.

Thank you for using our service. If you have any questions regarding PIRAT, please contact us at [email protected].


Best regards,
your PIRAT-Team";
                var content     = ConstructEmailText(region, germanText, englishText);
                await SendMailAsync(demandInformation.senderEmail, subject, content);
            });
        }
예제 #3
0
        public async Task SendDemandMailToProviderAsync(string region, ContactInformationDemand demandInformation,
                                                        string mailAddressReceiver, string receiverMailUserName)
        {
            await Task.Run(async() =>
            {
                var subject = ConstructSubjectText(region, "Ihre Ressource wurde angefragt",
                                                   "Your resource was requested");

                // TODO Add details to the resource that was demanded.
                var germanText  = $@"Liebe/r {receiverMailUserName},

es gibt eine Anfrage für eine von Ihnen angebotene Ressource.

Im Folgenden finden Sie die Kontaktdaten des Anfragenden:

Name: {demandInformation.senderName}
Email: {demandInformation.senderEmail}
{(!string.IsNullOrEmpty(demandInformation.senderPhone) ? ("Telefonnummer: " + demandInformation.senderPhone) : "")}
Institution: {demandInformation.senderInstitution}

Folgende Nachricht wurde für Sie hinterlassen:

{demandInformation.message}

Bitte nehmen Sie Kontakt zum Anfragenden auf und klären Sie alle weiteren Details des Austausches direkt miteinander.

Vielen Dank, dass Sie unser Angebot genutzt haben. Falls Sie noch Fragen zu PIRAT haben, melden Sie sich gerne jederzeit unter [email protected].


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

A request was registered for a resource you offered via PIRAT.

In the following you can see the contact details of the person interested in an exchange:

Name: {demandInformation.senderName}
Email: {demandInformation.senderEmail}
{(!string.IsNullOrEmpty(demandInformation.senderPhone) ? ("Phone: " + demandInformation.senderPhone) : "")}
Institution: {demandInformation.senderInstitution}

The following message was sent:

{demandInformation.message}

Please contact the requesting person and arrange the terms of the resource interchange in direct agreement.

Thank you for using our service. If you have any questions regarding PIRAT, please contact us at [email protected].


Best regards,
your PIRAT-Team";
                var content     = ConstructEmailText(region, germanText, englishText);
                await SendMailAsync(mailAddressReceiver, subject, content);
            });
        }
예제 #4
0
        public async Task <IActionResult> ConsumableAnonymousContactAsync([FromBody] ContactInformationDemand contactInformationDemand, int id)
        {
            NullCheck.ThrowIfNull <ContactInformationDemand>(contactInformationDemand);

            try
            {
                _mailInputValidatorService.validateMail(contactInformationDemand.senderEmail);
                ConsumableDemandEntity consumable = await _resourceDemandQueryService.FindAsync(new ConsumableDemandEntity(), id);

                if (consumable is null)
                {
                    return(NotFound(FailureCodes.NotFoundDevice));
                }

                DemandEntity demand = await _resourceDemandQueryService.FindAsync(new DemandEntity(), consumable.demand_id);

                if (demand is null)
                {
                    return(NotFound(FailureCodes.NotFoundOffer));
                }

                var resourceNameDE = _languageDE.Consumable[consumable.category];
                var resourceNameEN = _languageEN.Consumable[consumable.category];

                var mailAddressReceiver  = demand.mail;
                var mailUserNameReceiver = demand.name;
                // TODO
                var region = "de";
                await _mailService.SendOfferMailToDemanderAsync(region, contactInformationDemand, mailAddressReceiver,
                                                                mailUserNameReceiver, resourceNameDE, resourceNameEN);

                await _mailService.SendDemandConformationMailToDemanderAsync(region, contactInformationDemand);

                return(Ok());
            }
            catch (ArgumentException e)
            {
                return(BadRequest(e.Message));
            }
        }