Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions TailoredApps.Shared.sln
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,20 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TailoredApps.Shared.Payment
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TailoredApps.Shared.Payments.Provider.Stripe", "src\TailoredApps.Shared.Payments.Provider.Stripe\TailoredApps.Shared.Payments.Provider.Stripe.csproj", "{A1B2C3D4-E5F6-7890-ABCD-EF1234567890}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TailoredApps.Shared.Payments.Provider.Adyen", "src\TailoredApps.Shared.Payments.Provider.Adyen\TailoredApps.Shared.Payments.Provider.Adyen.csproj", "{B1C2D3E4-F5A6-7890-BCDE-FA2345678901}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TailoredApps.Shared.Payments.Provider.PayU", "src\TailoredApps.Shared.Payments.Provider.PayU\TailoredApps.Shared.Payments.Provider.PayU.csproj", "{C2D3E4F5-A6B7-8901-CDEF-AB3456789012}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TailoredApps.Shared.Payments.Provider.Przelewy24", "src\TailoredApps.Shared.Payments.Provider.Przelewy24\TailoredApps.Shared.Payments.Provider.Przelewy24.csproj", "{D3E4F5A6-B7C8-9012-DEF0-BC4567890123}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TailoredApps.Shared.Payments.Provider.Tpay", "src\TailoredApps.Shared.Payments.Provider.Tpay\TailoredApps.Shared.Payments.Provider.Tpay.csproj", "{E4F5A6B7-C8D9-0123-EF01-CD5678901234}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TailoredApps.Shared.Payments.Provider.HotPay", "src\TailoredApps.Shared.Payments.Provider.HotPay\TailoredApps.Shared.Payments.Provider.HotPay.csproj", "{F5A6B7C8-D9E0-1234-F012-DE6789012345}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TailoredApps.Shared.Payments.Provider.PayNow", "src\TailoredApps.Shared.Payments.Provider.PayNow\TailoredApps.Shared.Payments.Provider.PayNow.csproj", "{A6B7C8D9-E0F1-2345-0123-EF7890123456}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TailoredApps.Shared.Payments.Provider.Revolut", "src\TailoredApps.Shared.Payments.Provider.Revolut\TailoredApps.Shared.Payments.Provider.Revolut.csproj", "{B7C8D9E0-F1A2-3456-1234-F08901234567}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TailoredApps.Shared.EntityFramework.UnitOfWork.WebApiCore", "src\TailoredApps.Shared.EntityFramework.UnitOfWork.WebApiCore\TailoredApps.Shared.EntityFramework.UnitOfWork.WebApiCore.csproj", "{5C6FFD3B-B9E3-47D8-8A77-5973198C7B16}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TailoredApps.Shared.MediatR.ML", "src\TailoredApps.Shared.MediatR.ML\TailoredApps.Shared.MediatR.ML.csproj", "{C454266F-AF6D-450B-B899-9359180BAE94}"
Expand Down Expand Up @@ -127,6 +141,34 @@ Global
{A1B2C3D4-E5F6-7890-ABCD-EF1234567890}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A1B2C3D4-E5F6-7890-ABCD-EF1234567890}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A1B2C3D4-E5F6-7890-ABCD-EF1234567890}.Release|Any CPU.Build.0 = Release|Any CPU
{B1C2D3E4-F5A6-7890-BCDE-FA2345678901}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B1C2D3E4-F5A6-7890-BCDE-FA2345678901}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B1C2D3E4-F5A6-7890-BCDE-FA2345678901}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B1C2D3E4-F5A6-7890-BCDE-FA2345678901}.Release|Any CPU.Build.0 = Release|Any CPU
{C2D3E4F5-A6B7-8901-CDEF-AB3456789012}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C2D3E4F5-A6B7-8901-CDEF-AB3456789012}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C2D3E4F5-A6B7-8901-CDEF-AB3456789012}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C2D3E4F5-A6B7-8901-CDEF-AB3456789012}.Release|Any CPU.Build.0 = Release|Any CPU
{D3E4F5A6-B7C8-9012-DEF0-BC4567890123}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D3E4F5A6-B7C8-9012-DEF0-BC4567890123}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D3E4F5A6-B7C8-9012-DEF0-BC4567890123}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D3E4F5A6-B7C8-9012-DEF0-BC4567890123}.Release|Any CPU.Build.0 = Release|Any CPU
{E4F5A6B7-C8D9-0123-EF01-CD5678901234}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E4F5A6B7-C8D9-0123-EF01-CD5678901234}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E4F5A6B7-C8D9-0123-EF01-CD5678901234}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E4F5A6B7-C8D9-0123-EF01-CD5678901234}.Release|Any CPU.Build.0 = Release|Any CPU
{F5A6B7C8-D9E0-1234-F012-DE6789012345}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F5A6B7C8-D9E0-1234-F012-DE6789012345}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F5A6B7C8-D9E0-1234-F012-DE6789012345}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F5A6B7C8-D9E0-1234-F012-DE6789012345}.Release|Any CPU.Build.0 = Release|Any CPU
{A6B7C8D9-E0F1-2345-0123-EF7890123456}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A6B7C8D9-E0F1-2345-0123-EF7890123456}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A6B7C8D9-E0F1-2345-0123-EF7890123456}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A6B7C8D9-E0F1-2345-0123-EF7890123456}.Release|Any CPU.Build.0 = Release|Any CPU
{B7C8D9E0-F1A2-3456-1234-F08901234567}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B7C8D9E0-F1A2-3456-1234-F08901234567}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B7C8D9E0-F1A2-3456-1234-F08901234567}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B7C8D9E0-F1A2-3456-1234-F08901234567}.Release|Any CPU.Build.0 = Release|Any CPU
{5C6FFD3B-B9E3-47D8-8A77-5973198C7B16}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5C6FFD3B-B9E3-47D8-8A77-5973198C7B16}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5C6FFD3B-B9E3-47D8-8A77-5973198C7B16}.Release|Any CPU.ActiveCfg = Release|Any CPU
Expand Down
50 changes: 33 additions & 17 deletions src/TailoredApps.Shared.Email.Models/MailMessage.cs
Original file line number Diff line number Diff line change
@@ -1,17 +1,33 @@
using System;
using System.Collections.Generic;

namespace TailoredApps.Shared.Email.Models
{
public class MailMessage
{
public string Topic { get; set; }
public string Sender { get; set; }
public string Recipent { get; set; }
public string Copy { get; set; }
public string Body { get; set; }
public string HtmlBody { get; set; }
public Dictionary<string, string> Attachements { get; set; }
public DateTimeOffset Date { get; set; }
}
}
using System;
using System.Collections.Generic;

namespace TailoredApps.Shared.Email.Models
{
/// <summary>Model wiadomości e-mail.</summary>
public class MailMessage
{
/// <summary>Temat wiadomości.</summary>
public string Topic { get; set; }

/// <summary>Nadawca wiadomości.</summary>
public string Sender { get; set; }

/// <summary>Odbiorca wiadomości.</summary>
public string Recipent { get; set; }

/// <summary>Kopia CC wiadomości.</summary>
public string Copy { get; set; }

/// <summary>Treść wiadomości (plain text).</summary>
public string Body { get; set; }

/// <summary>Treść wiadomości (HTML).</summary>
public string HtmlBody { get; set; }

/// <summary>Załączniki: nazwa pliku → zawartość Base64.</summary>
public Dictionary<string, string> Attachements { get; set; }

/// <summary>Data wysłania wiadomości.</summary>
public DateTimeOffset Date { get; set; }
}
}
47 changes: 25 additions & 22 deletions src/TailoredApps.Shared.Email/EmailServiceToConsolleWritter.cs
Original file line number Diff line number Diff line change
@@ -1,22 +1,25 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using TailoredApps.Shared.Email.Models;

namespace TailoredApps.Shared.Email
{
public class EmailServiceToConsolleWritter : IEmailProvider
{
public async Task<ICollection<MailMessage>> GetMail(string folder = "", string sender = "", string recipent = "", TimeSpan? fromLast = null)
{
return new List<MailMessage>();
}

public async Task<string> SendMail(string recipnet, string topic, string messageBody, Dictionary<string, byte[]> attachments)
{
var message = $"recipent: {recipnet}; topic: {topic}; message: {messageBody}";
Console.WriteLine(message);
return message;
}
}
}
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using TailoredApps.Shared.Email.Models;

namespace TailoredApps.Shared.Email
{
/// <summary>Implementacja <see cref="IEmailProvider"/> wypisująca wiadomości na konsolę (dev/test).</summary>
public class EmailServiceToConsolleWritter : IEmailProvider
{
/// <inheritdoc/>
public async Task<ICollection<MailMessage>> GetMail(string folder = "", string sender = "", string recipent = "", TimeSpan? fromLast = null)
{
return new List<MailMessage>();
}

/// <inheritdoc/>
public async Task<string> SendMail(string recipnet, string topic, string messageBody, Dictionary<string, byte[]> attachments)
{
var message = $"recipent: {recipnet}; topic: {topic}; message: {messageBody}";
Console.WriteLine(message);
return message;
}
}
}
31 changes: 17 additions & 14 deletions src/TailoredApps.Shared.Email/IEmailProvider.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
using System;
using System.Collections.Generic;
using System.Net.Mail;
using System.Threading.Tasks;

namespace TailoredApps.Shared.Email
{
public interface IEmailProvider
{
Task<string> SendMail(string recipnet, string topic, string messageBody, Dictionary<string, byte[]> attachments);
Task<ICollection<Models.MailMessage>> GetMail(string folder = "", string sender = "", string recipent = "", TimeSpan? fromLast = null);

}
}
using System;
using System.Collections.Generic;
using System.Net.Mail;
using System.Threading.Tasks;

namespace TailoredApps.Shared.Email
{
/// <summary>Interfejs dostawcy e-mail — wysyłanie i odbieranie wiadomości.</summary>
public interface IEmailProvider
{
/// <summary>Wywołanie API.</summary>
Task<string> SendMail(string recipnet, string topic, string messageBody, Dictionary<string, byte[]> attachments);
/// <summary>Wywołanie API.</summary>
Task<ICollection<Models.MailMessage>> GetMail(string folder = "", string sender = "", string recipent = "", TimeSpan? fromLast = null);

}
}
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
using System.Collections.Generic;

namespace TailoredApps.Shared.Email.MailMessageBuilder
{
public class DefaultMessageBuilder : IMailMessageBuilder
{
public string Build(string templateKey, IDictionary<string, string> variables, IDictionary<string, string> templates)
{
if (templates.ContainsKey(templateKey))
{
var templateTransform = templates[templateKey];
foreach (var token in variables)
{
templateTransform = templateTransform.Replace(token.Key, token.Value);
}
return templateTransform;
}
throw new KeyNotFoundException("templateKey");
}
}
}
using System.Collections.Generic;

namespace TailoredApps.Shared.Email.MailMessageBuilder
{
/// <summary>Domyślna implementacja <see cref="IMailMessageBuilder"/> — zastępuje tokeny w szablonie.</summary>
public class DefaultMessageBuilder : IMailMessageBuilder
{
/// <inheritdoc/>
public string Build(string templateKey, IDictionary<string, string> variables, IDictionary<string, string> templates)
{
if (templates.ContainsKey(templateKey))
{
var templateTransform = templates[templateKey];
foreach (var token in variables)
{
templateTransform = templateTransform.Replace(token.Key, token.Value);
}
return templateTransform;
}
throw new KeyNotFoundException("templateKey");
}
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
using System.Collections.Generic;

namespace TailoredApps.Shared.Email.MailMessageBuilder
{
public interface IMailMessageBuilder
{
string Build(string templateKey, IDictionary<string, string> variables, IDictionary<string, string> templates);
}
}
using System.Collections.Generic;

namespace TailoredApps.Shared.Email.MailMessageBuilder
{
/// <summary>Interfejs budowania treści wiadomości e-mail z szablonu.</summary>
public interface IMailMessageBuilder
{
/// <summary>Buduje treść wiadomości na podstawie klucza szablonu i zmiennych.</summary>
string Build(string templateKey, IDictionary<string, string> variables, IDictionary<string, string> templates);
}
}
Original file line number Diff line number Diff line change
@@ -1,48 +1,53 @@
using Microsoft.Extensions.Options;
using System.Collections.Generic;
using System.IO;

namespace TailoredApps.Shared.Email.MailMessageBuilder
{
public class TokenReplacingMailMessageBuilder : IMailMessageBuilder
{
private readonly IOptions<TokenReplacingMailMessageBuilderOptions> options;
public TokenReplacingMailMessageBuilder(IOptions<TokenReplacingMailMessageBuilderOptions> options)
{
this.options = options;
}
public string Build(string templateKey, IDictionary<string, string> variables, IDictionary<string, string> templates)
{
if (templates == null)
{
templates = new Dictionary<string, string>();
}

if (options != null && options.Value != null && !string.IsNullOrEmpty(options.Value.Location))
{
var files = new DirectoryInfo(options.Value.Location).GetFiles($"*.{options.Value.FileExtension}", SearchOption.AllDirectories);
foreach (var file in files)
{
if (!templates.ContainsKey(file.Name))
{
var template = file.OpenText().ReadToEnd();
templates.Add(templateKey, template);
}
}
}

if (templates.ContainsKey(templateKey))
{
var template = templates[templateKey];
foreach (var key in variables.Keys)
{
template = template.Replace(@"{{" + key + "}}", variables[key]);
}
return template;
}

throw new KeyNotFoundException("templateKey");
}

}
}
using Microsoft.Extensions.Options;
using System.Collections.Generic;
using System.IO;

namespace TailoredApps.Shared.Email.MailMessageBuilder
{
/// <summary>Buduje wiadomości e-mail z szablonów z podmianą tokenów.</summary>
public class TokenReplacingMailMessageBuilder : IMailMessageBuilder
{
private readonly IOptions<TokenReplacingMailMessageBuilderOptions> options;

/// <summary>Inicjalizuje instancję <see cref="TokenReplacingMailMessageBuilder"/>.</summary>
public TokenReplacingMailMessageBuilder(IOptions<TokenReplacingMailMessageBuilderOptions> options)
{
this.options = options;
}

/// <inheritdoc/>
public string Build(string templateKey, IDictionary<string, string> variables, IDictionary<string, string> templates)
{
if (templates == null)
{
templates = new Dictionary<string, string>();
}

if (options != null && options.Value != null && !string.IsNullOrEmpty(options.Value.Location))
{
var files = new DirectoryInfo(options.Value.Location).GetFiles($"*.{options.Value.FileExtension}", SearchOption.AllDirectories);
foreach (var file in files)
{
if (!templates.ContainsKey(file.Name))
{
var template = file.OpenText().ReadToEnd();
templates.Add(templateKey, template);
}
}
}

if (templates.ContainsKey(templateKey))
{
var template = templates[templateKey];
foreach (var key in variables.Keys)
{
template = template.Replace(@"{{" + key + "}}", variables[key]);
}
return template;
}

throw new KeyNotFoundException("templateKey");
}

}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
namespace TailoredApps.Shared.Email.MailMessageBuilder
{
public class TokenReplacingMailMessageBuilderOptions
{
public string Location { get; set; }
public string FileExtension { get; set; }
}
}
namespace TailoredApps.Shared.Email.MailMessageBuilder
{
/// <summary>Opcje <see cref="TokenReplacingMailMessageBuilder"/> — lokalizacja i rozszerzenie szablonów.</summary>
public class TokenReplacingMailMessageBuilderOptions
{
/// <summary>Location.</summary>
public string Location { get; set; }
/// <summary>FileExtension.</summary>
public string FileExtension { get; set; }
}
}
Loading
Loading