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/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..1e2a8f17 100644 --- a/ServiceHost/Pages/Index.cshtml.cs +++ b/ServiceHost/Pages/Index.cshtml.cs @@ -85,71 +85,132 @@ namespace ServiceHost.Pages //اصلاحات محاصبه پایه سنوات در فیش حقوقی //_yearlySalaryRepository.TestDayliFeeCompute(); bool ex = false; - //while (!ex) - //{ - // Console.WriteLine("enter National code ... "); - // var nationalCode = Console.ReadLine(); - // Console.WriteLine("enter DateOfBirth ... "); - // var dateOfBirth = Console.ReadLine(); - // Console.WriteLine("enter phoneNumber ... "); - // var phone = Console.ReadLine(); - // var res = _clientRegistrationApplication.CreateContractingPartyTemp(nationalCode, dateOfBirth, phone).GetAwaiter().GetResult(); - // if (res.IsSuccedded) - // { - // var updateAddress = - // _clientRegistrationApplication.UpdateAddress(res.Data.Id, "gilan", "rasht", "hajiabad").GetAwaiter().GetResult(); - // 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(); - // Console.WriteLine("sumOfWorkshopPayment : " + result.SumOfWorkshopsPaymentDouble); - // Console.WriteLine("TotalPaymentDouble : " + result.TotalPaymentDouble); - // } - // else - // { - // var workshops = new List(); - // workshops.Add(new WorkshopTempViewModel - // { - // ContractAndCheckout = true, - // ContractingPartyTempId = res.Data.Id, - // CountPerson = 10, - // CustomizeCheckout = true, - // Insurance = true, - // RollCall = true, - // WorkshopName = "dadmehr", + while (!ex) + { + Console.WriteLine("enter National code ... "); + var nationalCode = Console.ReadLine(); + Console.WriteLine("enter DateOfBirth ... "); + var dateOfBirth = Console.ReadLine(); + Console.WriteLine("enter phoneNumber ... "); + var phone = Console.ReadLine(); + var res = await _clientRegistrationApplication.CreateContractingPartyTemp(nationalCode, dateOfBirth, + phone); + if (res.IsSuccedded) + { + 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 = 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(); - // }); - // workshops.Add(new WorkshopTempViewModel - // { - // ContractAndCheckout = true, - // ContractingPartyTempId = res.Data.Id, - // CountPerson = 20, - // CustomizeCheckout = true, - // Insurance = true, - // RollCall = true, - // WorkshopName = "kababMahdi", + 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); + } + } + } + } - // }); - // var creteWorkshops = _clientRegistrationApplication.CreateOrUpdateWorkshopTemp(workshops) - // .GetAwaiter().GetResult(); + } + else + { + var workshops = new List(); + workshops.Add(new WorkshopTempViewModel + { + ContractAndCheckout = true, + ContractingPartyTempId = res.Data.Id, + CountPerson = 10, + CustomizeCheckout = true, + Insurance = true, + RollCall = true, + WorkshopName = "dadmehr", - // if (creteWorkshops.IsSuccedded) - // { - // var result = _clientRegistrationApplication.GetTotalPaymentAndWorkshopList(res.Data.Id).GetAwaiter().GetResult(); - // Console.WriteLine("sumOfWorkshopPayment : " + result.SumOfWorkshopsPaymentDouble); - // Console.WriteLine("TotalPaymentDouble : " + result.TotalPaymentDouble); - // } - // } + }); + workshops.Add(new WorkshopTempViewModel + { + ContractAndCheckout = true, + ContractingPartyTempId = res.Data.Id, + CountPerson = 20, + CustomizeCheckout = true, + Insurance = true, + RollCall = true, + WorkshopName = "kababMahdi", - // } - // } - // Console.WriteLine("do you want to exit ... "); - // var exitCheck = Console.ReadLine(); - // if (exitCheck == "yes") - // ex = true; - //} + }); + var creteWorkshops = _clientRegistrationApplication.CreateOrUpdateWorkshopTemp(workshops) + .GetAwaiter().GetResult(); + + if (creteWorkshops.IsSuccedded) + { + 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 == "y") + ex = true; + } // while (!ex) // {