diff --git a/0_Framework/Application/Sms/ISmsService.cs b/0_Framework/Application/Sms/ISmsService.cs index 9b0d2937..d16ef5f2 100644 --- a/0_Framework/Application/Sms/ISmsService.cs +++ b/0_Framework/Application/Sms/ISmsService.cs @@ -9,6 +9,13 @@ public interface ISmsService void Send(string number, string message); bool VerifySend(string number, string message); bool LoginSend(string number, string message); + /// + /// ارسال کد به کلاینت برای تکمیل فرایند ثبت نام + /// + /// + /// + /// + Task SendVerifyCodeToClient(string number, string code); bool SendAccountsInfo(string number,string fullName, string userName); Task GetByMessageId(int messId); Task> GetApiResult(string startDate, string endDate); diff --git a/0_Framework/Application/Sms/SentSmsViewModel.cs b/0_Framework/Application/Sms/SentSmsViewModel.cs new file mode 100644 index 00000000..70539933 --- /dev/null +++ b/0_Framework/Application/Sms/SentSmsViewModel.cs @@ -0,0 +1,32 @@ +namespace _0_Framework.Application; + +public class SentSmsViewModel +{ + public SentSmsViewModel() + { + IsSuccedded = false; + } + + public bool IsSuccedded { get; set; } + public string Message { get; set; } + public byte StatusCode { get; set; } + public int MessageId { get; set; } + + public SentSmsViewModel Succedded(byte statusCode, string message, int messageId) + { + IsSuccedded = true; + Message = message; + StatusCode = statusCode; + MessageId = messageId; + return this; + } + + public SentSmsViewModel Failed(byte statusCode, string message, int messageId) + { + IsSuccedded = false; + Message = message; + StatusCode = statusCode; + MessageId = messageId; + return this; + } +} \ No newline at end of file diff --git a/0_Framework/Application/Sms/SmsService.cs b/0_Framework/Application/Sms/SmsService.cs index e6947ebb..4db0caa7 100644 --- a/0_Framework/Application/Sms/SmsService.cs +++ b/0_Framework/Application/Sms/SmsService.cs @@ -9,6 +9,7 @@ using IPE.SmsIrClient; using IPE.SmsIrClient.Models.Requests; using IPE.SmsIrClient.Models.Results; using Microsoft.Extensions.Configuration; +using static System.Runtime.InteropServices.JavaScript.JSType; namespace _0_Framework.Application.Sms; @@ -110,6 +111,31 @@ public class SmsService : ISmsService } } + public async Task SendVerifyCodeToClient(string number, string code) + { + SmsIr smsIr = new SmsIr("Og5M562igmzJRhQPnq0GdtieYdLgtfikjzxOmeQBPxJjZtyge5Klc046Lfw1mxSa"); + var result = new SentSmsViewModel(); + //var bulkSendResult = smsIr.BulkSendAsync(95007079000006, "your text message", new string[] { "9120000000" }); + + var sendResult = await smsIr.VerifySendAsync(number, 768382, new VerifySendParameter[] { new VerifySendParameter("VerificationCode", code) }); + Thread.Sleep(2000); + + if (sendResult.Message == "موفق") + { + var status = sendResult.Status; + var message = sendResult.Message; + var messaeId = sendResult.Data.MessageId; + return result.Succedded(status, message, messaeId); + } + else + { + var status = sendResult.Status; + var message = sendResult.Message; + var messaeId = sendResult.Data.MessageId; + return result.Failed(status, message, messaeId); + } + } + public bool SendAccountsInfo(string number, string fullName, string userName) { diff --git a/AccountManagement.Domain/TaskScheduleAgg/TaskSchedule.cs b/AccountManagement.Domain/TaskScheduleAgg/TaskSchedule.cs index 6f54d275..d7ac1550 100644 --- a/AccountManagement.Domain/TaskScheduleAgg/TaskSchedule.cs +++ b/AccountManagement.Domain/TaskScheduleAgg/TaskSchedule.cs @@ -16,14 +16,14 @@ public class TaskSchedule:EntityBase UnitType = unitType; UnitNumber = unitNumber; LastEndTaskDate = lastEndTaskDate; - IsCanceled = IsActive.True; + IsActive = IsActive.False; } public string Count { get; private set; } public TaskScheduleType Type { get; private set; } public TaskScheduleUnitType UnitType { get; private set; } public string UnitNumber { get; private set; } public DateTime LastEndTaskDate { get; private set; } - public IsActive IsCanceled { get; private set; } + public IsActive IsActive { get; private set; } public List TasksList { get; set; } public void SetLastEndTaskDate(DateTime lastEndTaskDate) @@ -33,6 +33,6 @@ public class TaskSchedule:EntityBase public void DeActive() { - IsCanceled = IsActive.False; + IsActive = IsActive.False; } } \ No newline at end of file diff --git a/AccountMangement.Infrastructure.EFCore/Mappings/TaskScheduleMapping.cs b/AccountMangement.Infrastructure.EFCore/Mappings/TaskScheduleMapping.cs index ff388549..d8d2efe2 100644 --- a/AccountMangement.Infrastructure.EFCore/Mappings/TaskScheduleMapping.cs +++ b/AccountMangement.Infrastructure.EFCore/Mappings/TaskScheduleMapping.cs @@ -15,7 +15,7 @@ public class TaskScheduleMapping : IEntityTypeConfiguration builder.Property(x => x.Type).HasConversion().HasMaxLength(12); builder.Property(x => x.UnitNumber).HasMaxLength(10); builder.Property(x => x.UnitType).HasConversion().HasMaxLength(10); - builder.Property(x => x.IsCanceled).HasConversion().HasMaxLength(5); + builder.Property(x => x.IsActive).HasConversion().HasMaxLength(5); builder.HasMany(x => x.TasksList).WithOne(x => x.TaskSchedule) .HasForeignKey(x => x.TaskScheduleId); diff --git a/AccountMangement.Infrastructure.EFCore/Migrations/20250416121822_taskSchedule rename isActive.Designer.cs b/AccountMangement.Infrastructure.EFCore/Migrations/20250416121822_taskSchedule rename isActive.Designer.cs new file mode 100644 index 00000000..bb8c382a --- /dev/null +++ b/AccountMangement.Infrastructure.EFCore/Migrations/20250416121822_taskSchedule rename isActive.Designer.cs @@ -0,0 +1,1274 @@ +// +using System; +using AccountMangement.Infrastructure.EFCore; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace AccountMangement.Infrastructure.EFCore.Migrations +{ + [DbContext(typeof(AccountContext))] + [Migration("20250416121822_taskSchedule rename isActive")] + partial class taskSchedulerenameisActive + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "8.0.10") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("AccountManagement.Domain.AccountAgg.Account", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("id")); + + b.Property("AdminAreaPermission") + .HasMaxLength(10) + .HasColumnType("nvarchar(10)"); + + b.Property("ClientAriaPermission") + .HasMaxLength(10) + .HasColumnType("nvarchar(10)"); + + b.Property("CreationDate") + .HasColumnType("datetime2"); + + b.Property("Email") + .HasMaxLength(150) + .HasColumnType("nvarchar(150)"); + + b.Property("Fullname") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("IsActiveString") + .HasMaxLength(6) + .HasColumnType("nvarchar(6)"); + + b.Property("Mobile") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("nvarchar(20)"); + + b.Property("NationalCode") + .HasMaxLength(10) + .HasColumnType("nvarchar(10)"); + + b.Property("Password") + .IsRequired() + .HasMaxLength(1000) + .HasColumnType("nvarchar(1000)"); + + b.Property("PositionId") + .HasMaxLength(10) + .HasColumnType("bigint"); + + b.Property("PositionIsActive") + .HasMaxLength(5) + .HasColumnType("nvarchar(5)"); + + b.Property("ProfilePhoto") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("RoleId") + .HasColumnType("bigint"); + + b.Property("RoleName") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("Username") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("VerifyCode") + .HasMaxLength(1000) + .HasColumnType("nvarchar(1000)"); + + b.HasKey("id"); + + b.HasIndex("PositionId"); + + b.HasIndex("RoleId"); + + b.ToTable("Accounts", (string)null); + }); + + modelBuilder.Entity("AccountManagement.Domain.AccountLeftWorkAgg.AccountLeftWork", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("id")); + + b.Property("AccountId") + .HasColumnType("bigint"); + + b.Property("CreationDate") + .HasColumnType("datetime2"); + + b.Property("IsActive") + .HasColumnType("bit"); + + b.Property("LeftWorkGr") + .HasColumnType("datetime2"); + + b.Property("RoleId") + .HasColumnType("bigint"); + + b.Property("StartWorkGr") + .HasColumnType("datetime2"); + + b.Property("WorkshopId") + .HasColumnType("bigint"); + + b.HasKey("id"); + + b.HasIndex("AccountId"); + + b.ToTable("AccountLeftWork", (string)null); + }); + + modelBuilder.Entity("AccountManagement.Domain.AdminResponseAgg.AdminResponse", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("id")); + + b.Property("AdminAccountId") + .HasColumnType("bigint"); + + b.Property("CreationDate") + .HasColumnType("datetime2"); + + b.Property("IsActiveString") + .HasMaxLength(5) + .HasColumnType("nvarchar(5)"); + + b.Property("Response") + .HasColumnType("ntext"); + + b.Property("TicketId") + .HasColumnType("bigint"); + + b.HasKey("id"); + + b.HasIndex("TicketId"); + + b.ToTable("AdminResponses", (string)null); + }); + + modelBuilder.Entity("AccountManagement.Domain.AdminResponseMediaAgg.AdminResponseMedia", b => + { + b.Property("AdminResponseId") + .HasColumnType("bigint"); + + b.Property("MediaId") + .HasColumnType("bigint"); + + b.HasKey("AdminResponseId", "MediaId"); + + b.HasIndex("MediaId"); + + b.ToTable("AdminResponseMedias", (string)null); + }); + + modelBuilder.Entity("AccountManagement.Domain.AssignAgg.Assign", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("id")); + + b.Property("AcceptedTimeRequest") + .HasColumnType("int"); + + b.Property("AssignedId") + .HasColumnType("bigint"); + + b.Property("AssignedName") + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("AssignedPositionValue") + .HasColumnType("int"); + + b.Property("AssignerId") + .HasColumnType("bigint"); + + b.Property("AssignerPositionValue") + .HasColumnType("int"); + + b.Property("CancelDescription") + .HasColumnType("ntext"); + + b.Property("CreationDate") + .HasColumnType("datetime2"); + + b.Property("DoneDescription") + .HasColumnType("ntext"); + + b.Property("EndTaskDate") + .HasColumnType("datetime2"); + + b.Property("FirstTimeCreation") + .HasColumnType("bit"); + + b.Property("IsCancel") + .HasColumnType("bit"); + + b.Property("IsCanceledRequest") + .HasColumnType("bit"); + + b.Property("IsDone") + .HasColumnType("bit"); + + b.Property("IsDoneRequest") + .HasColumnType("bit"); + + b.Property("RequestDate") + .HasColumnType("datetime2"); + + b.Property("TaskId") + .HasColumnType("bigint"); + + b.Property("TimeRequest") + .HasColumnType("bit"); + + b.Property("TimeRequestDescription") + .HasColumnType("ntext"); + + b.HasKey("id"); + + b.HasIndex("TaskId"); + + b.ToTable("Assigns", (string)null); + }); + + modelBuilder.Entity("AccountManagement.Domain.CameraAccountAgg.CameraAccount", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("id")); + + b.Property("AccountId") + .HasColumnType("bigint"); + + b.Property("CreationDate") + .HasColumnType("datetime2"); + + b.Property("IsActiveSting") + .IsRequired() + .HasMaxLength(5) + .HasColumnType("nvarchar(5)"); + + b.Property("Mobile") + .HasMaxLength(11) + .HasColumnType("nvarchar(11)"); + + b.Property("Password") + .IsRequired() + .HasMaxLength(1000) + .HasColumnType("nvarchar(1000)"); + + b.Property("Username") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("WorkshopId") + .HasColumnType("bigint"); + + b.Property("WorkshopName") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.HasKey("id"); + + b.HasIndex("AccountId"); + + b.ToTable("CameraAccounts", (string)null); + }); + + modelBuilder.Entity("AccountManagement.Domain.ClientResponseAgg.ClientResponse", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("id")); + + b.Property("CreationDate") + .HasColumnType("datetime2"); + + b.Property("Response") + .HasColumnType("ntext"); + + b.Property("TicketId") + .HasColumnType("bigint"); + + b.HasKey("id"); + + b.HasIndex("TicketId"); + + b.ToTable("ClientResponses", (string)null); + }); + + modelBuilder.Entity("AccountManagement.Domain.ClientResponseMediaAgg.ClientResponseMedia", b => + { + b.Property("ClientResponseId") + .HasColumnType("bigint"); + + b.Property("MediaId") + .HasColumnType("bigint"); + + b.HasKey("ClientResponseId", "MediaId"); + + b.HasIndex("MediaId"); + + b.ToTable("ClientResponseMedias", (string)null); + }); + + modelBuilder.Entity("AccountManagement.Domain.MediaAgg.Media", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("id")); + + b.Property("Category") + .HasMaxLength(10) + .HasColumnType("nvarchar(10)"); + + b.Property("CreationDate") + .HasColumnType("datetime2"); + + b.Property("Path") + .HasColumnType("ntext"); + + b.Property("ServiceName") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("Type") + .HasMaxLength(10) + .HasColumnType("nvarchar(10)"); + + b.HasKey("id"); + + b.ToTable("Medias", (string)null); + }); + + modelBuilder.Entity("AccountManagement.Domain.PositionAgg.Position", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("id")); + + b.Property("CreationDate") + .HasColumnType("datetime2"); + + b.Property("PositionName") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("PositionValue") + .HasMaxLength(2) + .HasColumnType("int"); + + b.HasKey("id"); + + b.ToTable("Positions", (string)null); + }); + + modelBuilder.Entity("AccountManagement.Domain.RoleAgg.Role", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("id")); + + b.Property("CreationDate") + .HasColumnType("datetime2"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.HasKey("id"); + + b.ToTable("Roles", (string)null); + }); + + modelBuilder.Entity("AccountManagement.Domain.SubAccountAgg.SubAccount", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("id")); + + b.Property("AccountId") + .HasColumnType("bigint"); + + b.Property("CreationDate") + .HasColumnType("datetime2"); + + b.Property("FName") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("IsActive") + .IsRequired() + .HasMaxLength(5) + .HasColumnType("nvarchar(5)"); + + b.Property("LName") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("NationalCode") + .HasMaxLength(10) + .HasColumnType("nvarchar(10)"); + + b.Property("Password") + .IsRequired() + .HasMaxLength(1000) + .HasColumnType("nvarchar(1000)"); + + b.Property("PhoneNumber") + .IsRequired() + .HasMaxLength(11) + .HasColumnType("nvarchar(11)"); + + b.Property("ProfilePhoto") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("SubAccountRoleId") + .HasColumnType("bigint"); + + b.Property("Username") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("VerifyCode") + .HasMaxLength(10) + .HasColumnType("nvarchar(10)"); + + b.HasKey("id"); + + b.HasIndex("SubAccountRoleId"); + + b.ToTable("SubAccounts", (string)null); + }); + + modelBuilder.Entity("AccountManagement.Domain.SubAccountPermissionSubtitle1Agg.SubAccountPermissionSubtitle1", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("id")); + + b.Property("Code") + .HasMaxLength(15) + .HasColumnType("int"); + + b.Property("CreationDate") + .HasColumnType("datetime2"); + + b.Property("Title") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.HasKey("id"); + + b.ToTable("SubAccountPermissionSubtitle1", (string)null); + }); + + modelBuilder.Entity("AccountManagement.Domain.SubAccountPermissionSubtitle2Agg.SubAccountPermissionSubtitle2", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("id")); + + b.Property("Code") + .HasMaxLength(15) + .HasColumnType("int"); + + b.Property("CreationDate") + .HasColumnType("datetime2"); + + b.Property("ParentId") + .HasColumnType("bigint"); + + b.Property("Title") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.HasKey("id"); + + b.HasIndex("ParentId"); + + b.ToTable("SubAccountPermissionSubtitle2", (string)null); + }); + + modelBuilder.Entity("AccountManagement.Domain.SubAccountPermissionSubtitle3Agg.SubAccountPermissionSubtitle3", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("id")); + + b.Property("Code") + .HasMaxLength(15) + .HasColumnType("int"); + + b.Property("CreationDate") + .HasColumnType("datetime2"); + + b.Property("ParentId") + .HasColumnType("bigint"); + + b.Property("Title") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.HasKey("id"); + + b.HasIndex("ParentId"); + + b.ToTable("SubAccountPermissionSubtitle3", (string)null); + }); + + modelBuilder.Entity("AccountManagement.Domain.SubAccountPermissionSubtitle4Agg.SubAccountPermissionSubtitle4", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("id")); + + b.Property("Code") + .HasMaxLength(15) + .HasColumnType("int"); + + b.Property("CreationDate") + .HasColumnType("datetime2"); + + b.Property("ParentId") + .HasColumnType("bigint"); + + b.Property("Title") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.HasKey("id"); + + b.HasIndex("ParentId"); + + b.ToTable("SubAccountPermissionSubtitle4", (string)null); + }); + + modelBuilder.Entity("AccountManagement.Domain.SubAccountRoleAgg.SubAccountRole", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("id")); + + b.Property("AccountId") + .HasColumnType("bigint"); + + b.Property("CreationDate") + .HasColumnType("datetime2"); + + b.Property("Title") + .HasMaxLength(60) + .HasColumnType("nvarchar(60)"); + + b.HasKey("id"); + + b.ToTable("SubAccountRoles", (string)null); + }); + + modelBuilder.Entity("AccountManagement.Domain.TaskAgg.Tasks", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("id")); + + b.Property("ContractingPartyName") + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("CreationDate") + .HasColumnType("datetime2"); + + b.Property("Description") + .HasColumnType("ntext"); + + b.Property("IsActiveString") + .HasMaxLength(7) + .HasColumnType("nvarchar(7)"); + + b.Property("SenderId") + .HasColumnType("bigint"); + + b.Property("StartTaskDate") + .HasColumnType("datetime2"); + + b.Property("TaskScheduleId") + .HasColumnType("bigint"); + + b.Property("TicketId") + .HasColumnType("bigint"); + + b.Property("Title") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.HasKey("id"); + + b.HasIndex("TaskScheduleId"); + + b.ToTable("TasksManager", (string)null); + }); + + modelBuilder.Entity("AccountManagement.Domain.TaskMediaAgg.TaskMedia", b => + { + b.Property("MediaId") + .HasColumnType("bigint"); + + b.Property("TaskId") + .HasColumnType("bigint"); + + b.HasKey("MediaId", "TaskId"); + + b.HasIndex("TaskId"); + + b.ToTable("TasksMedias", (string)null); + }); + + modelBuilder.Entity("AccountManagement.Domain.TaskMessageAgg.TaskMessage", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("id")); + + b.Property("AssignId") + .HasColumnType("bigint"); + + b.Property("CreationDate") + .HasColumnType("datetime2"); + + b.Property("Message") + .HasColumnType("ntext"); + + b.Property("RequestedDateFa") + .HasMaxLength(25) + .HasColumnType("nvarchar(25)"); + + b.Property("TypeOfMessage") + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b.HasKey("id"); + + b.HasIndex("AssignId"); + + b.ToTable("TaskMessages", (string)null); + }); + + modelBuilder.Entity("AccountManagement.Domain.TaskMessageItemsAgg.TaskMessageItems", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("id")); + + b.Property("CreationDate") + .HasColumnType("datetime2"); + + b.Property("ReceiverAccountId") + .HasColumnType("bigint"); + + b.Property("SenderAccountId") + .HasColumnType("bigint"); + + b.Property("TaskMessageId") + .HasColumnType("bigint"); + + b.HasKey("id"); + + b.HasIndex("TaskMessageId"); + + b.ToTable("TaskMessageItems", (string)null); + }); + + modelBuilder.Entity("AccountManagement.Domain.TaskScheduleAgg.TaskSchedule", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("id")); + + b.Property("Count") + .HasMaxLength(10) + .HasColumnType("nvarchar(10)"); + + b.Property("CreationDate") + .HasColumnType("datetime2"); + + b.Property("IsActive") + .IsRequired() + .HasMaxLength(5) + .HasColumnType("nvarchar(5)"); + + b.Property("LastEndTaskDate") + .HasColumnType("datetime2"); + + b.Property("Type") + .IsRequired() + .HasMaxLength(12) + .HasColumnType("nvarchar(12)"); + + b.Property("UnitNumber") + .HasMaxLength(10) + .HasColumnType("nvarchar(10)"); + + b.Property("UnitType") + .IsRequired() + .HasMaxLength(10) + .HasColumnType("nvarchar(10)"); + + b.HasKey("id"); + + b.ToTable("TaskSchedules", (string)null); + }); + + modelBuilder.Entity("AccountManagement.Domain.TaskSubjectAgg.TaskSubject", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("id")); + + b.Property("CreationDate") + .HasColumnType("datetime2"); + + b.Property("Subject") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.HasKey("id"); + + b.ToTable("TaskSubjects", (string)null); + }); + + modelBuilder.Entity("AccountManagement.Domain.TicketAccessAccountAgg.TicketAccessAccount", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("id")); + + b.Property("AccountId") + .HasColumnType("bigint"); + + b.Property("CreationDate") + .HasColumnType("datetime2"); + + b.HasKey("id"); + + b.ToTable("TicketAccessAccounts", (string)null); + }); + + modelBuilder.Entity("AccountManagement.Domain.TicketAgg.Ticket", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("id")); + + b.Property("ContractingPartyName") + .HasMaxLength(155) + .HasColumnType("nvarchar(155)"); + + b.Property("CreationDate") + .HasColumnType("datetime2"); + + b.Property("Description") + .HasColumnType("ntext"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("SenderId") + .HasColumnType("bigint"); + + b.Property("Status") + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b.Property("SubAccountSenderId") + .HasColumnType("bigint"); + + b.Property("TicketNumber") + .HasMaxLength(12) + .HasColumnType("nvarchar(12)"); + + b.Property("TicketType") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("Title") + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("WorkshopId") + .HasColumnType("bigint"); + + b.HasKey("id"); + + b.ToTable("Tickets", (string)null); + }); + + modelBuilder.Entity("AccountManagement.Domain.TicketMediasAgg.TicketMedia", b => + { + b.Property("TicketId") + .HasColumnType("bigint"); + + b.Property("MediaId") + .HasColumnType("bigint"); + + b.HasKey("TicketId", "MediaId"); + + b.HasIndex("MediaId"); + + b.ToTable("TicketMedias", (string)null); + }); + + modelBuilder.Entity("AccountManagement.Domain.AccountAgg.Account", b => + { + b.HasOne("AccountManagement.Domain.PositionAgg.Position", "Position") + .WithMany("Accounts") + .HasForeignKey("PositionId"); + + b.HasOne("AccountManagement.Domain.RoleAgg.Role", "Role") + .WithMany("Accounts") + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Position"); + + b.Navigation("Role"); + }); + + modelBuilder.Entity("AccountManagement.Domain.AccountLeftWorkAgg.AccountLeftWork", b => + { + b.HasOne("AccountManagement.Domain.AccountAgg.Account", "Account") + .WithMany("AccountLeftWorkList") + .HasForeignKey("AccountId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Account"); + }); + + modelBuilder.Entity("AccountManagement.Domain.AdminResponseAgg.AdminResponse", b => + { + b.HasOne("AccountManagement.Domain.TicketAgg.Ticket", "Ticket") + .WithMany("AdminResponses") + .HasForeignKey("TicketId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Ticket"); + }); + + modelBuilder.Entity("AccountManagement.Domain.AdminResponseMediaAgg.AdminResponseMedia", b => + { + b.HasOne("AccountManagement.Domain.AdminResponseAgg.AdminResponse", "AdminResponse") + .WithMany("AdminResponseMedias") + .HasForeignKey("AdminResponseId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("AccountManagement.Domain.MediaAgg.Media", "Media") + .WithMany("AdminResponseMedias") + .HasForeignKey("MediaId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("AdminResponse"); + + b.Navigation("Media"); + }); + + modelBuilder.Entity("AccountManagement.Domain.AssignAgg.Assign", b => + { + b.HasOne("AccountManagement.Domain.TaskAgg.Tasks", "Task") + .WithMany("Assigns") + .HasForeignKey("TaskId") + .OnDelete(DeleteBehavior.Cascade); + + b.Navigation("Task"); + }); + + modelBuilder.Entity("AccountManagement.Domain.CameraAccountAgg.CameraAccount", b => + { + b.HasOne("AccountManagement.Domain.AccountAgg.Account", "Account") + .WithMany("CameraAccounts") + .HasForeignKey("AccountId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Account"); + }); + + modelBuilder.Entity("AccountManagement.Domain.ClientResponseAgg.ClientResponse", b => + { + b.HasOne("AccountManagement.Domain.TicketAgg.Ticket", "Ticket") + .WithMany("ClientResponses") + .HasForeignKey("TicketId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Ticket"); + }); + + modelBuilder.Entity("AccountManagement.Domain.ClientResponseMediaAgg.ClientResponseMedia", b => + { + b.HasOne("AccountManagement.Domain.ClientResponseAgg.ClientResponse", "ClientResponse") + .WithMany("ClientResponseMedias") + .HasForeignKey("ClientResponseId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("AccountManagement.Domain.MediaAgg.Media", "Media") + .WithMany("ClientResponseMedias") + .HasForeignKey("MediaId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("ClientResponse"); + + b.Navigation("Media"); + }); + + modelBuilder.Entity("AccountManagement.Domain.RoleAgg.Role", b => + { + b.OwnsMany("AccountManagement.Domain.RoleAgg.Permission", "Permissions", b1 => + { + b1.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b1.Property("Id")); + + b1.Property("Code") + .HasColumnType("int"); + + b1.Property("RoleId") + .HasColumnType("bigint"); + + b1.HasKey("Id"); + + b1.HasIndex("RoleId"); + + b1.ToTable("RolePermissions", (string)null); + + b1.WithOwner("Role") + .HasForeignKey("RoleId"); + + b1.Navigation("Role"); + }); + + b.Navigation("Permissions"); + }); + + modelBuilder.Entity("AccountManagement.Domain.SubAccountAgg.SubAccount", b => + { + b.HasOne("AccountManagement.Domain.SubAccountRoleAgg.SubAccountRole", "SubAccountRole") + .WithMany("SubAccounts") + .HasForeignKey("SubAccountRoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("SubAccountRole"); + }); + + modelBuilder.Entity("AccountManagement.Domain.SubAccountPermissionSubtitle2Agg.SubAccountPermissionSubtitle2", b => + { + b.HasOne("AccountManagement.Domain.SubAccountPermissionSubtitle1Agg.SubAccountPermissionSubtitle1", "Parent") + .WithMany("Children") + .HasForeignKey("ParentId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Parent"); + }); + + modelBuilder.Entity("AccountManagement.Domain.SubAccountPermissionSubtitle3Agg.SubAccountPermissionSubtitle3", b => + { + b.HasOne("AccountManagement.Domain.SubAccountPermissionSubtitle2Agg.SubAccountPermissionSubtitle2", "Parent") + .WithMany("Children") + .HasForeignKey("ParentId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Parent"); + }); + + modelBuilder.Entity("AccountManagement.Domain.SubAccountPermissionSubtitle4Agg.SubAccountPermissionSubtitle4", b => + { + b.HasOne("AccountManagement.Domain.SubAccountPermissionSubtitle3Agg.SubAccountPermissionSubtitle3", "Parent") + .WithMany("Children") + .HasForeignKey("ParentId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Parent"); + }); + + modelBuilder.Entity("AccountManagement.Domain.SubAccountRoleAgg.SubAccountRole", b => + { + b.OwnsMany("AccountManagement.Domain.SubAccountRoleAgg.SubAccountRolePermission", "RolePermissions", b1 => + { + b1.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b1.Property("id")); + + b1.Property("PermissionCode") + .HasColumnType("int"); + + b1.Property("SubAccountRoleId") + .HasColumnType("bigint"); + + b1.HasKey("id"); + + b1.HasIndex("SubAccountRoleId"); + + b1.ToTable("SubAccountRolePermissions", (string)null); + + b1.WithOwner("SubAccountRole") + .HasForeignKey("SubAccountRoleId"); + + b1.Navigation("SubAccountRole"); + }); + + b.Navigation("RolePermissions"); + }); + + modelBuilder.Entity("AccountManagement.Domain.TaskAgg.Tasks", b => + { + b.HasOne("AccountManagement.Domain.TaskScheduleAgg.TaskSchedule", "TaskSchedule") + .WithMany("TasksList") + .HasForeignKey("TaskScheduleId") + .OnDelete(DeleteBehavior.Cascade); + + b.Navigation("TaskSchedule"); + }); + + modelBuilder.Entity("AccountManagement.Domain.TaskMediaAgg.TaskMedia", b => + { + b.HasOne("AccountManagement.Domain.MediaAgg.Media", "Media") + .WithMany("TaskMedias") + .HasForeignKey("MediaId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("AccountManagement.Domain.TaskAgg.Tasks", "Tasks") + .WithMany("TaskMedias") + .HasForeignKey("TaskId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Media"); + + b.Navigation("Tasks"); + }); + + modelBuilder.Entity("AccountManagement.Domain.TaskMessageAgg.TaskMessage", b => + { + b.HasOne("AccountManagement.Domain.AssignAgg.Assign", "Assign") + .WithMany("TaskMessageList") + .HasForeignKey("AssignId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Assign"); + }); + + modelBuilder.Entity("AccountManagement.Domain.TaskMessageItemsAgg.TaskMessageItems", b => + { + b.HasOne("AccountManagement.Domain.TaskMessageAgg.TaskMessage", "TaskMessage") + .WithMany("TaskMessageItemsList") + .HasForeignKey("TaskMessageId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("TaskMessage"); + }); + + modelBuilder.Entity("AccountManagement.Domain.TicketMediasAgg.TicketMedia", b => + { + b.HasOne("AccountManagement.Domain.MediaAgg.Media", "Media") + .WithMany("TicketMedias") + .HasForeignKey("MediaId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("AccountManagement.Domain.TicketAgg.Ticket", "Ticket") + .WithMany("TicketMedias") + .HasForeignKey("TicketId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Media"); + + b.Navigation("Ticket"); + }); + + modelBuilder.Entity("AccountManagement.Domain.AccountAgg.Account", b => + { + b.Navigation("AccountLeftWorkList"); + + b.Navigation("CameraAccounts"); + }); + + modelBuilder.Entity("AccountManagement.Domain.AdminResponseAgg.AdminResponse", b => + { + b.Navigation("AdminResponseMedias"); + }); + + modelBuilder.Entity("AccountManagement.Domain.AssignAgg.Assign", b => + { + b.Navigation("TaskMessageList"); + }); + + modelBuilder.Entity("AccountManagement.Domain.ClientResponseAgg.ClientResponse", b => + { + b.Navigation("ClientResponseMedias"); + }); + + modelBuilder.Entity("AccountManagement.Domain.MediaAgg.Media", b => + { + b.Navigation("AdminResponseMedias"); + + b.Navigation("ClientResponseMedias"); + + b.Navigation("TaskMedias"); + + b.Navigation("TicketMedias"); + }); + + modelBuilder.Entity("AccountManagement.Domain.PositionAgg.Position", b => + { + b.Navigation("Accounts"); + }); + + modelBuilder.Entity("AccountManagement.Domain.RoleAgg.Role", b => + { + b.Navigation("Accounts"); + }); + + modelBuilder.Entity("AccountManagement.Domain.SubAccountPermissionSubtitle1Agg.SubAccountPermissionSubtitle1", b => + { + b.Navigation("Children"); + }); + + modelBuilder.Entity("AccountManagement.Domain.SubAccountPermissionSubtitle2Agg.SubAccountPermissionSubtitle2", b => + { + b.Navigation("Children"); + }); + + modelBuilder.Entity("AccountManagement.Domain.SubAccountPermissionSubtitle3Agg.SubAccountPermissionSubtitle3", b => + { + b.Navigation("Children"); + }); + + modelBuilder.Entity("AccountManagement.Domain.SubAccountRoleAgg.SubAccountRole", b => + { + b.Navigation("SubAccounts"); + }); + + modelBuilder.Entity("AccountManagement.Domain.TaskAgg.Tasks", b => + { + b.Navigation("Assigns"); + + b.Navigation("TaskMedias"); + }); + + modelBuilder.Entity("AccountManagement.Domain.TaskMessageAgg.TaskMessage", b => + { + b.Navigation("TaskMessageItemsList"); + }); + + modelBuilder.Entity("AccountManagement.Domain.TaskScheduleAgg.TaskSchedule", b => + { + b.Navigation("TasksList"); + }); + + modelBuilder.Entity("AccountManagement.Domain.TicketAgg.Ticket", b => + { + b.Navigation("AdminResponses"); + + b.Navigation("ClientResponses"); + + b.Navigation("TicketMedias"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/AccountMangement.Infrastructure.EFCore/Migrations/20250416121822_taskSchedule rename isActive.cs b/AccountMangement.Infrastructure.EFCore/Migrations/20250416121822_taskSchedule rename isActive.cs new file mode 100644 index 00000000..ca1e230d --- /dev/null +++ b/AccountMangement.Infrastructure.EFCore/Migrations/20250416121822_taskSchedule rename isActive.cs @@ -0,0 +1,28 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace AccountMangement.Infrastructure.EFCore.Migrations +{ + /// + public partial class taskSchedulerenameisActive : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.RenameColumn( + name: "IsCanceled", + table: "TaskSchedules", + newName: "IsActive"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.RenameColumn( + name: "IsActive", + table: "TaskSchedules", + newName: "IsCanceled"); + } + } +} diff --git a/AccountMangement.Infrastructure.EFCore/Migrations/AccountContextModelSnapshot.cs b/AccountMangement.Infrastructure.EFCore/Migrations/AccountContextModelSnapshot.cs index 3770c043..153816a2 100644 --- a/AccountMangement.Infrastructure.EFCore/Migrations/AccountContextModelSnapshot.cs +++ b/AccountMangement.Infrastructure.EFCore/Migrations/AccountContextModelSnapshot.cs @@ -759,7 +759,7 @@ namespace AccountMangement.Infrastructure.EFCore.Migrations b.Property("CreationDate") .HasColumnType("datetime2"); - b.Property("IsCanceled") + b.Property("IsActive") .IsRequired() .HasMaxLength(5) .HasColumnType("nvarchar(5)"); diff --git a/Company.Domain/TemporaryClientRegistrationAgg/IContractingPartyTempRepository.cs b/Company.Domain/TemporaryClientRegistrationAgg/IContractingPartyTempRepository.cs index 223b466a..8be4c97b 100644 --- a/Company.Domain/TemporaryClientRegistrationAgg/IContractingPartyTempRepository.cs +++ b/Company.Domain/TemporaryClientRegistrationAgg/IContractingPartyTempRepository.cs @@ -20,4 +20,11 @@ public interface IContractingPartyTempRepository :IRepository /// ContractingPartyTempViewModel GetByNationalCode(string nationalCode); + + /// + /// دریافت اطلاعات طرف حساب موقت با کد ملی + /// + /// + /// + ContractingPartyTempViewModel GetByContractingPartyTempId(long contractingPartyTempId); } \ No newline at end of file diff --git a/Company.Domain/TemporaryClientRegistrationAgg/InstitutionContractTemp.cs b/Company.Domain/TemporaryClientRegistrationAgg/InstitutionContractTemp.cs index 89b1a746..62974a44 100644 --- a/Company.Domain/TemporaryClientRegistrationAgg/InstitutionContractTemp.cs +++ b/Company.Domain/TemporaryClientRegistrationAgg/InstitutionContractTemp.cs @@ -1,5 +1,6 @@ using System; using System.Threading.Tasks; +using _0_Framework.Application.UID; using _0_Framework.Domain; namespace Company.Domain.TemporaryClientRegistrationAgg; @@ -119,4 +120,15 @@ public class InstitutionContractTemp : EntityBase VerifyCodeEndTime = verifyCodeEndTime; } + public void Update(string verifyCode, string registrationStatus, int messageId, DateTime? sendVerifyCodeTime, DateTime? verifyCodeEndTime) + { + VerifyCode = verifyCode; + RegistrationStatus = registrationStatus; + MessageId = messageId; + SendVerifyCodeTime = sendVerifyCodeTime; + VerifyCodeEndTime = verifyCodeEndTime; + } + + + } \ No newline at end of file diff --git a/CompanyManagment.App.Contracts/TemporaryClientRegistration/CreateInstitutionContractTemp.cs b/CompanyManagment.App.Contracts/TemporaryClientRegistration/CreateInstitutionContractTemp.cs index 9a755441..85594646 100644 --- a/CompanyManagment.App.Contracts/TemporaryClientRegistration/CreateInstitutionContractTemp.cs +++ b/CompanyManagment.App.Contracts/TemporaryClientRegistration/CreateInstitutionContractTemp.cs @@ -63,6 +63,8 @@ public class CreateInstitutionContractTemp /// - /// VerifyCodeSent کد ارسال شده /// - + /// ReceivedCodeFromClient + /// - /// Completed ثبت نام تکمیل شده /// public string RegistrationStatus { get; set; } diff --git a/CompanyManagment.App.Contracts/TemporaryClientRegistration/ITemporaryClientRegistrationApplication.cs b/CompanyManagment.App.Contracts/TemporaryClientRegistration/ITemporaryClientRegistrationApplication.cs index cfaabc9e..17ed2570 100644 --- a/CompanyManagment.App.Contracts/TemporaryClientRegistration/ITemporaryClientRegistrationApplication.cs +++ b/CompanyManagment.App.Contracts/TemporaryClientRegistration/ITemporaryClientRegistrationApplication.cs @@ -62,5 +62,34 @@ public interface ITemporaryClientRegistrationApplication /// /// /// - Task CreateOrUpdateInstitutionContractTemp(long contractingPartyTempId, string periodModel, string paymentModel); + Task CreateOrUpdateInstitutionContractTemp(long contractingPartyTempId, string periodModel, string paymentModel, double totalPayment, double valueAddedTax); + + /// + /// دریافت کد برای کلاینت + /// از طرف سرور + /// + /// + /// + Task ReceivedCodeFromServer(long contractingPartyTempId); + + /// + /// ورود کد از طرف کلاینت + /// برا چک کردن + /// + /// + /// + /// + Task CheckVerifyCodeIsTrue(long contractingPartyTempId, string verifyCode); + + + + + + /// + /// تکمیل پرداخت + /// + /// + /// + /// + Task PayOffCompleted(long contractingPartyTempId); } \ No newline at end of file diff --git a/CompanyManagment.Application/SmsResultApplication.cs b/CompanyManagment.Application/SmsResultApplication.cs index 98b07fe6..03f01b29 100644 --- a/CompanyManagment.Application/SmsResultApplication.cs +++ b/CompanyManagment.Application/SmsResultApplication.cs @@ -25,7 +25,7 @@ public class SmsResultApplication : ISmsResultApplication return op.Succcedded(); } - public List Search(SmsResultSearchModel searchModel) + public List Search(SmsResultSearchModel searchModel) { var result = _smsResultRepository.Search(searchModel); diff --git a/CompanyManagment.Application/TemporaryClientRegistrationApplication.cs b/CompanyManagment.Application/TemporaryClientRegistrationApplication.cs index 913eb7a9..b774eed6 100644 --- a/CompanyManagment.Application/TemporaryClientRegistrationApplication.cs +++ b/CompanyManagment.Application/TemporaryClientRegistrationApplication.cs @@ -1,13 +1,16 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using _0_Framework.Application; +using _0_Framework.Application.Sms; using _0_Framework.Application.UID; using Company.Domain.ContarctingPartyAgg; using Company.Domain.InstitutionPlanAgg; using Company.Domain.TemporaryClientRegistrationAgg; using CompanyManagment.App.Contracts.InstitutionPlan; using CompanyManagment.App.Contracts.TemporaryClientRegistration; +using IPE.SmsIrClient.Models.Results; using Microsoft.EntityFrameworkCore; using PersianTools.Core; @@ -22,8 +25,9 @@ public class TemporaryClientRegistrationApplication : ITemporaryClientRegistrati private readonly IPlanPercentageRepository _planPercentageRepository; private readonly IWorkshopServicesTempRepository _workshopServicesTempRepository; private readonly IInstitutionContractTempRepository _institutionContractTempRepository; + private readonly ISmsService _smsService; - public TemporaryClientRegistrationApplication(IContractingPartyTempRepository contractingPartyTempRepository, IPersonalContractingPartyRepository personalContractingPartyRepository, IUidService uidService, IWorkshopTempRepository workshopTempRepository, IPlanPercentageRepository planPercentageRepository, IWorkshopServicesTempRepository workshopServicesTempRepository, IInstitutionContractTempRepository institutionContractTempRepository) + public TemporaryClientRegistrationApplication(IContractingPartyTempRepository contractingPartyTempRepository, IPersonalContractingPartyRepository personalContractingPartyRepository, IUidService uidService, IWorkshopTempRepository workshopTempRepository, IPlanPercentageRepository planPercentageRepository, IWorkshopServicesTempRepository workshopServicesTempRepository, IInstitutionContractTempRepository institutionContractTempRepository, ISmsService smsService) { _contractingPartyTempRepository = contractingPartyTempRepository; _personalContractingPartyRepository = personalContractingPartyRepository; @@ -32,6 +36,7 @@ public class TemporaryClientRegistrationApplication : ITemporaryClientRegistrati _planPercentageRepository = planPercentageRepository; _workshopServicesTempRepository = workshopServicesTempRepository; _institutionContractTempRepository = institutionContractTempRepository; + _smsService = smsService; } /// @@ -60,6 +65,9 @@ public class TemporaryClientRegistrationApplication : ITemporaryClientRegistrati if (!mobile.IsMobileValid()) return op.Failed("شماره همراه نا معتبر است"); + + + #endregion @@ -82,6 +90,15 @@ public class TemporaryClientRegistrationApplication : ITemporaryClientRegistrati //اگر طرف حساب موقت قبلا ایجاد شده دیتای آن را برمیگرداند if (getExistTemp != null) { + var institutionContractTemp = await + _institutionContractTempRepository.GetInstitutionContractTemp(0, getExistTemp.Id); + + if (institutionContractTemp != null) + { + + if (institutionContractTemp.RegistrationStatus == "Completed") + return op.Failed("شما قبلا ثبت نام خود را تکمیل نموده اید"); + } if (getExistTemp.DateOfBirth != dateOfBirthGr) return op.Failed("تاریخ تولد مطابقت ندارد"); @@ -396,19 +413,192 @@ public class TemporaryClientRegistrationApplication : ITemporaryClientRegistrati /// /// /// - public async Task CreateOrUpdateInstitutionContractTemp(long contractingPartyTempId, string periodModel, string paymentModel) + public async Task CreateOrUpdateInstitutionContractTemp(long contractingPartyTempId, string periodModel, string paymentModel, double totalPayment, double valueAddedTax) { var op = new OperationResult(); - var contractingPartyTemp = await + var institutionContractTemp = await _institutionContractTempRepository.GetInstitutionContractTemp(0, contractingPartyTempId); - if (contractingPartyTemp == null) + if (institutionContractTemp == null) + { + var periodModelInt = Convert.ToInt32(periodModel); + var contractstart = DateTime.Now; + var contractEnd = DateTime.Now.AddMonths(periodModelInt); + var create = new InstitutionContractTemp(contractingPartyTempId,paymentModel,periodModel,totalPayment,contractstart,contractEnd,"official", valueAddedTax,"", "BeforeSendVerifyCode", 0,null,null); + _institutionContractTempRepository.Create(create); + _institutionContractTempRepository.SaveChanges(); + return op.Succcedded(); + } + else + { + if (institutionContractTemp.VerifyCodeEndTime != null) + { + var spaning = (institutionContractTemp.VerifyCodeEndTime.Value - DateTime.Now); + if (institutionContractTemp.RegistrationStatus == "VerifyCodeSent" && spaning > new TimeSpan(0, 0, 0) && spaning < new TimeSpan(0, 1, 0)) + return op.Failed("شما به تازگی پیامک دریافت نموده اید دو دقیقه صبر کنید و دوباره تلاش کنید"); + } + + if (institutionContractTemp.RegistrationStatus == "Completed") + return op.Failed("شما قبلا ثبت نام خود را تکمیل نموده اید"); + - return op.Failed(""); - - throw new System.NotImplementedException(); + var periodModelInt = Convert.ToInt32(periodModel); + var contractstart = DateTime.Now; + var contractEnd = DateTime.Now.AddMonths(periodModelInt); + var update = _institutionContractTempRepository.Get(institutionContractTemp.Id); + update.Edit(contractingPartyTempId, paymentModel, periodModel, totalPayment, contractstart, contractEnd, "official", valueAddedTax, "", "BeforeSendVerifyCode", 0, null, null); + _institutionContractTempRepository.SaveChanges(); + return op.Succcedded(); + } } + + + /// + /// دریافت کد برای کلاینت + /// از طرف سرور + /// + /// + /// + public async Task ReceivedCodeFromServer(long contractingPartyTempId) + { + + var op = new OperationResult(); + var institutionContractTemp = await + _institutionContractTempRepository.GetInstitutionContractTemp(0, contractingPartyTempId); + if (institutionContractTemp == null) + return op.Failed("خظا"); + + var update = _institutionContractTempRepository.Get(institutionContractTemp.Id); + + + + + if (institutionContractTemp.RegistrationStatus == "BeforeSendVerifyCode") + { + //ساخت کد شش رقمی + Random generator = new Random(); + String code = generator.Next(1, 1000000).ToString("D6"); + //ارسال اس ام اس + var getContractingPaty = _contractingPartyTempRepository.GetByContractingPartyTempId(contractingPartyTempId); + var sendResult = await _smsService.SendVerifyCodeToClient(getContractingPaty.Phone, code); + + if (!sendResult.IsSuccedded) + return op.Failed($"{sendResult.Message}"); + + //ذخیره کد در دیتا بیس + //ذخیره تاریخ ارسال و مهلت پایان + //ذخیره آیدی پیامک + //تغییر وضعیت به ارسال شده + if (update != null) + { + update.Update(code, "VerifyCodeSent", sendResult.MessageId, DateTime.Now, DateTime.Now.AddMinutes(2)); + _institutionContractTempRepository.SaveChanges(); + return op.Succcedded(1, "کد برای شما پیامک شد"); + } + + + } + + if (institutionContractTemp.RegistrationStatus == "VerifyCodeSent") + + { + var spaning = (institutionContractTemp.VerifyCodeEndTime.Value - DateTime.Now); + if ((spaning > new TimeSpan(0, 0, 0) && spaning < new TimeSpan(0, 1, 0))) + return op.Failed("شما به تازگی پیامک دریافت نموده اید دو دقیقه صبر کنید و دوباره تلاش کنید"); + + if ((spaning > new TimeSpan(0, 0, 0) && spaning > new TimeSpan(0, 1, 0))) + { + //ساخت کد شش رقمی + Random generator = new Random(); + String code = generator.Next(1, 1000000).ToString("D6"); + //ارسال اس ام اس + var getContractingPaty = _contractingPartyTempRepository.GetByContractingPartyTempId(contractingPartyTempId); + var sendResult =await _smsService.SendVerifyCodeToClient(getContractingPaty.Phone, code); + + if(!sendResult.IsSuccedded) + return op.Failed($"{sendResult.Message}"); + + + + //ذخیره کد در دیتا بیس + //ذخیره تاریخ ارسال و مهلت پایان + //ذخیره آیدی پیامک + //تغییر وضعیت به ارسال شده + + if (update != null) + { + update.Update(code, "VerifyCodeSent",sendResult.MessageId, DateTime.Now, DateTime.Now.AddMinutes(2)); + _institutionContractTempRepository.SaveChanges(); + return op.Succcedded(1, "کد برای شما پیامک شد"); + } + + + + } + + } + + //if (institutionContractTemp.RegistrationStatus == "ReceivedCodeFromClient") + // return op.Succcedded(2, "انتقال به بخش پرداخت"); + + if (institutionContractTemp.RegistrationStatus == "Completed") + return op.Failed("شما قبلا ثبت نام خود را تکمیل نموده اید"); + return op.Failed("خظا"); + } + + /// + /// ورود کد از طرف کلاینت + /// برا چک کردن + /// + /// + /// + /// + public async Task CheckVerifyCodeIsTrue(long contractingPartyTempId, string verifyCode) + { + var op = new OperationResult(); + var institutionContractTemp = await + _institutionContractTempRepository.GetInstitutionContractTemp(0, contractingPartyTempId); + if (institutionContractTemp == null) + return op.Failed("خظا"); + if(institutionContractTemp.RegistrationStatus != "VerifyCodeSent") + return op.Failed("خطا"); + + if(institutionContractTemp.VerifyCodeEndTime < DateTime.Now) + return op.Failed("کد شما منقضی شده است"); + + if(institutionContractTemp.SendVerifyCodeTime < DateTime.Now && institutionContractTemp.VerifyCodeEndTime >= DateTime.Now) + { + if (institutionContractTemp.VerifyCode == verifyCode) + { + + + return op.Succcedded(); + } + else + { + return op.Failed("کد وارد شده صحیح نیست"); + } + + } + + + return op.Failed("کد وارد شده صحیح نیست"); + } + + + /// + /// تکمیل پرداخت + /// + /// + /// + /// + public async Task PayOffCompleted(long contractingPartyTempId) + { + var op = new OperationResult(); + return op.Succcedded(); + } + } \ No newline at end of file diff --git a/CompanyManagment.EFCore/Repository/ContractingPartyTempRepository.cs b/CompanyManagment.EFCore/Repository/ContractingPartyTempRepository.cs index 195afbef..54ee843a 100644 --- a/CompanyManagment.EFCore/Repository/ContractingPartyTempRepository.cs +++ b/CompanyManagment.EFCore/Repository/ContractingPartyTempRepository.cs @@ -70,4 +70,30 @@ public class ContractingPartyTempRepository : RepositoryBase x.NationalCode == nationalCode); } + public ContractingPartyTempViewModel GetByContractingPartyTempId(long contractingPartyTempId) + { + return _context.ContractingPartyTemps.Select(x => new ContractingPartyTempViewModel + { + Id = x.id, + DateOfBirth = x.DateOfBirth, + DateOfBirthFa = x.DateOfBirth.ToFarsi(), + IdNumberSeri = x.IdNumberSeri, + IdNumberSerial = x.IdNumberSerial, + Address = x.Address, + City = x.City, + FatherName = x.FatherName, + FName = x.FName, + LName = x.LName, + Gender = x.Gender, + NationalCode = x.NationalCode, + IdNumber = x.IdNumber, + Phone = x.Phone, + State = x.State, + + + }).FirstOrDefault(x => x.Id == contractingPartyTempId); + + } + + } \ No newline at end of file diff --git a/CompanyManagment.EFCore/Repository/SmsResultRepository.cs b/CompanyManagment.EFCore/Repository/SmsResultRepository.cs index ec8fc153..0b555a7a 100644 --- a/CompanyManagment.EFCore/Repository/SmsResultRepository.cs +++ b/CompanyManagment.EFCore/Repository/SmsResultRepository.cs @@ -15,10 +15,10 @@ public class SmsResultRepository : RepositoryBase , ISmsResultR _context = context; } - public List Search(SmsResultSearchModel searchModel) + public List Search(SmsResultSearchModel searchModel) { - var query = _context.SmsResults.Select(x => new SmsResultViewModel() + var query = _context.SmsResults.Select(x => new App.Contracts.SmsResult.SmsResultViewModel() { Id = x.id, MessageId = x.MessageId, diff --git a/ServiceHost/Pages/Index.cshtml.cs b/ServiceHost/Pages/Index.cshtml.cs index 10b6bf6d..b75e8d2b 100644 --- a/ServiceHost/Pages/Index.cshtml.cs +++ b/ServiceHost/Pages/Index.cshtml.cs @@ -93,20 +93,52 @@ namespace ServiceHost.Pages // var dateOfBirth = Console.ReadLine(); // Console.WriteLine("enter phoneNumber ... "); // var phone = Console.ReadLine(); - // var res = _clientRegistrationApplication.CreateContractingPartyTemp(nationalCode, dateOfBirth, phone).GetAwaiter().GetResult(); + // var res = await _clientRegistrationApplication.CreateContractingPartyTemp(nationalCode, dateOfBirth, + // phone); // if (res.IsSuccedded) - // { - // var updateAddress = - // _clientRegistrationApplication.UpdateAddress(res.Data.Id, "gilan", "rasht", "hajiabad").GetAwaiter().GetResult(); + // { + // var updateAddress =await + // _clientRegistrationApplication.UpdateAddress(res.Data.Id, "gilan", "rasht", "hajiabad"); // if (updateAddress.IsSuccedded) // { // var workshopSelected = _clientRegistrationApplication.GetWorkshopTemp(res.Data.Id).GetAwaiter().GetResult(); // if (workshopSelected.Count > 0) - // { - // var result = _clientRegistrationApplication.GetTotalPaymentAndWorkshopList(res.Data.Id,"12","OneTime").GetAwaiter().GetResult(); + // { + // var result = await + // _clientRegistrationApplication.GetTotalPaymentAndWorkshopList(res.Data.Id, "12", + // "OneTime"); // Console.WriteLine("sumOfWorkshopPayment : " + result.SumOfWorkshopsPaymentDouble); // Console.WriteLine("TotalPaymentDouble : " + result.TotalPaymentDouble); - // } + // var createInstitutionContract = await + // _clientRegistrationApplication.CreateOrUpdateInstitutionContractTemp(res.Data.Id, null, + // null, result.TotalPaymentDouble, 0); + // if (createInstitutionContract.IsSuccedded) + // { + // var sendVerfyCode =await _clientRegistrationApplication.ReceivedCodeFromServer(res.Data.Id); + // if (sendVerfyCode.IsSuccedded) + // { + // Console.WriteLine("enter the code ... "); + // var codeReceived = Console.ReadLine(); + + // var completeSms = await + // _clientRegistrationApplication.CheckVerifyCodeIsTrue(res.Data.Id, codeReceived); + // if (completeSms.IsSuccedded) + // { + // var payOffCompleted = + // await _clientRegistrationApplication.PayOffCompleted(res.Data.Id); + // if (payOffCompleted.IsSuccedded) + // { + // Console.WriteLine("finaly completed"); + // } + // else + // { + // Console.WriteLine(payOffCompleted.Message); + // } + // } + // } + // } + + // } // else // { // var workshops = new List(); @@ -140,17 +172,51 @@ namespace ServiceHost.Pages // var result = _clientRegistrationApplication.GetTotalPaymentAndWorkshopList(res.Data.Id).GetAwaiter().GetResult(); // Console.WriteLine("sumOfWorkshopPayment : " + result.SumOfWorkshopsPaymentDouble); // Console.WriteLine("TotalPaymentDouble : " + result.TotalPaymentDouble); - // } + + // var createInstitutionContract = await + // _clientRegistrationApplication.CreateOrUpdateInstitutionContractTemp(res.Data.Id, null, + // null, result.TotalPaymentDouble, 0); + // if (createInstitutionContract.IsSuccedded) + // { + // var sendVerfyCode = await _clientRegistrationApplication.ReceivedCodeFromServer(res.Data.Id); + // if (sendVerfyCode.IsSuccedded) + // { + // Console.WriteLine("enter the code ... "); + // var codeReceived = Console.ReadLine(); + + // var completeSms = await + // _clientRegistrationApplication.CheckVerifyCodeIsTrue(res.Data.Id, codeReceived); + // if (completeSms.IsSuccedded) + // { + // var payOffCompleted = + // await _clientRegistrationApplication.PayOffCompleted(res.Data.Id); + // if (payOffCompleted.IsSuccedded) + // { + // Console.WriteLine("finaly completed"); + // } + // else + // { + // Console.WriteLine(payOffCompleted.Message); + // } + // } + // } + // } + // } // } // } // } // Console.WriteLine("do you want to exit ... "); // var exitCheck = Console.ReadLine(); - // if (exitCheck == "yes") + // if (exitCheck == "y") // ex = true; //} + + + + + // while (!ex) // { // var onGet = _institutionPlanApplication.GetByFirst();