feat: notify telegram on new inquiries
This commit is contained in:
@@ -9,6 +9,7 @@ public static class DependencyInjection
|
||||
{
|
||||
services.AddScoped<BlogService>();
|
||||
services.AddScoped<InquiryService>();
|
||||
services.AddScoped<IInquiryNotificationService, NoopInquiryNotificationService>();
|
||||
services.AddScoped<CategoryService>();
|
||||
return services;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
namespace TaxBaik.Application.Services;
|
||||
|
||||
public interface IInquiryNotificationService
|
||||
{
|
||||
Task NotifyCreatedAsync(int inquiryId, string name, string phone, string serviceType, string message, CancellationToken ct = default);
|
||||
}
|
||||
@@ -5,7 +5,7 @@ using TaxBaik.Domain.Entities;
|
||||
using TaxBaik.Domain.Enums;
|
||||
using TaxBaik.Domain.Interfaces;
|
||||
|
||||
public class InquiryService(IInquiryRepository repository)
|
||||
public class InquiryService(IInquiryRepository repository, IInquiryNotificationService notificationService)
|
||||
{
|
||||
private static readonly Regex PhoneRegex = new(@"^01[0-9]-\d{3,4}-\d{4}$");
|
||||
|
||||
@@ -34,7 +34,9 @@ public class InquiryService(IInquiryRepository repository)
|
||||
CreatedAt = DateTime.UtcNow
|
||||
};
|
||||
|
||||
return await repository.CreateAsync(inquiry, ct);
|
||||
var inquiryId = await repository.CreateAsync(inquiry, ct);
|
||||
await notificationService.NotifyCreatedAsync(inquiryId, inquiry.Name, inquiry.Phone, inquiry.ServiceType, inquiry.Message, ct);
|
||||
return inquiryId;
|
||||
}
|
||||
|
||||
public async Task<Inquiry?> GetByIdAsync(int id, CancellationToken ct = default) =>
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
namespace TaxBaik.Application.Services;
|
||||
|
||||
public sealed class NoopInquiryNotificationService : IInquiryNotificationService
|
||||
{
|
||||
public Task NotifyCreatedAsync(int inquiryId, string name, string phone, string serviceType, string message, CancellationToken ct = default)
|
||||
=> Task.CompletedTask;
|
||||
}
|
||||
Reference in New Issue
Block a user