This commit is contained in:
2026-06-04 09:44:23 +03:00
parent 4ddab34ad1
commit 033b4fc247
29 changed files with 3661 additions and 59 deletions
@@ -1,5 +1,8 @@
namespace MyOffice.Services.Account.Domain;
using AutoMapper;
using MyOffice.Data.Models.Accounts;
public class MotionDto
{
public Guid Id { get; set; }
@@ -13,4 +16,12 @@ public class MotionDto
public decimal AmountPlus { get; set; }
public decimal AmountMinus { get; set; }
public DateTime? DeletedOn { get; set; }
}
public class MotionDtoProfile: Profile
{
public MotionDtoProfile()
{
CreateMap<Motion, MotionDto>();
}
}
@@ -0,0 +1,80 @@
namespace MyOffice.Services.Notifications;
using MyOffice.Core;
using MyOffice.Data.Models.Notifications;
using MyOffice.Data.Models.Users;
using MyOffice.Data.Models.Verifications;
using MyOffice.Data.Repositories.Item;
using MyOffice.Services.Verifications;
public class EmailNotificationService
{
private readonly VerificationService _verificationService;
public EmailNotificationService(
VerificationService verificationService
)
{
_verificationService = verificationService;
}
public void PasswordResetEmail(User user)
{
var code = _verificationService.Add(
user,
user.Email,
VerificationCodeTemplateEnum.password_restore,
VerificationCodeTypeEnum.email
);
var subject = "";
var body = "";
}
}
public class TemplateSevice
{
private readonly IEmailTemplateRepository _emailTemplateRepository;
public TemplateSevice(
IEmailTemplateRepository emailTemplateRepository
)
{
_emailTemplateRepository = emailTemplateRepository;
}
public Exec<EmailTemplateFormated, GeneralExecStatus> GetTemplate(
EmailTemplateEnum template,
Dictionary<string, string> tokens
)
{
var result = new Exec<EmailTemplateFormated, GeneralExecStatus>(GeneralExecStatus.success);
var emailTemplate = _emailTemplateRepository.Get(template);
if (emailTemplate == null)
{
return result.Set(GeneralExecStatus.not_found);
}
result.Result = new EmailTemplateFormated
{
Subject = emailTemplate.Subject
Body = emailTemplate.Template,
};
return result;
}
}
public class EmailTemplateFormated
{
public string Sender { get; set; }
public string SenderName { get; set; }
public string Subject { get; set; }
public string Body { get; set; }
}
public interface IEmailSender
{
//Exec<bool, GeneralExecStatus> Send(string from, string[] to, string subject, string body);
}
@@ -0,0 +1,51 @@
namespace MyOffice.Services.Verifications;
using MyOffice.Core.Helpers;
using MyOffice.Data.Models.Users;
using MyOffice.Data.Models.Verifications;
using MyOffice.Data.Repositories.Item;
public class VerificationService
{
private readonly TimeSpan _defaultExpires = TimeSpan.FromDays(1);
private readonly IVerificationCodeRepository _verificationCodeRepository;
public VerificationService(
IVerificationCodeRepository verificationCodeRepository
)
{
_verificationCodeRepository = verificationCodeRepository;
}
public VerificationCode Add(
User user,
string destination,
VerificationCodeTemplateEnum template,
VerificationCodeTypeEnum type,
DateTime? expiresOn = null,
string? metadata = null
)
{
if (user == null)
throw new ArgumentNullException(nameof(user));
if (destination == null)
throw new ArgumentNullException(nameof(destination));
var verificationCode = new VerificationCode
{
UserId = user.Id,
Code = RandomizationHelper.Generate(40),
CreatedOn = DateTime.UtcNow,
ExpiresOn = expiresOn ?? DateTime.UtcNow.Add(_defaultExpires),
Template = template.ToString(),
DestinationType = type.ToString(),
Destination = destination,
Metadata = metadata,
};
_verificationCodeRepository.Add(verificationCode);
return verificationCode;
}
}