From d39dc5047ffb06fa8a03ca83dea589ff104f60f8 Mon Sep 17 00:00:00 2001 From: SamSys Date: Mon, 7 Apr 2025 19:50:33 +0330 Subject: [PATCH] TemporaryClient - WorkshopTemp and WorkshopServicesTemp --- .../ContractingPartyTemp.cs | 8 ++- .../IWorkshopServicesTempRepository.cs | 8 +++ .../IWorkshopTempRepository.cs | 18 +++++ .../WorkshopServicesTemp.cs | 34 ++++++++++ .../WorkshopTemp.cs | 48 ++++++++++++++ .../CreateWorkshopServicesTemp.cs | 19 ++++++ .../CreateWorkshopTemp.cs | 66 +++++++++++++++++++ ...ITemporaryClientRegistrationApplication.cs | 27 +++++++- .../WorkshopServicesTempViewModel.cs | 6 ++ .../WorkshopTempViewModel.cs | 6 ++ .../TemporaryClientRegistrationApplication.cs | 35 +++++++++- CompanyManagment.EFCore/CompanyContext.cs | 3 +- .../Mapping/WorkshopServicesTempMapping.cs | 20 ++++++ .../Mapping/WorkshopTempMapping.cs | 20 ++++++ .../ContractingPartyTempRepository.cs | 1 + .../Repository/WorkshopTempRepository.cs | 33 ++++++++++ 16 files changed, 347 insertions(+), 5 deletions(-) create mode 100644 Company.Domain/TemporaryClientRegistrationAgg/IWorkshopServicesTempRepository.cs create mode 100644 Company.Domain/TemporaryClientRegistrationAgg/IWorkshopTempRepository.cs create mode 100644 Company.Domain/TemporaryClientRegistrationAgg/WorkshopServicesTemp.cs create mode 100644 Company.Domain/TemporaryClientRegistrationAgg/WorkshopTemp.cs create mode 100644 CompanyManagment.App.Contracts/TemporaryClientRegistration/CreateWorkshopServicesTemp.cs create mode 100644 CompanyManagment.App.Contracts/TemporaryClientRegistration/CreateWorkshopTemp.cs create mode 100644 CompanyManagment.App.Contracts/TemporaryClientRegistration/WorkshopServicesTempViewModel.cs create mode 100644 CompanyManagment.App.Contracts/TemporaryClientRegistration/WorkshopTempViewModel.cs create mode 100644 CompanyManagment.EFCore/Mapping/WorkshopServicesTempMapping.cs create mode 100644 CompanyManagment.EFCore/Mapping/WorkshopTempMapping.cs create mode 100644 CompanyManagment.EFCore/Repository/WorkshopTempRepository.cs diff --git a/Company.Domain/TemporaryClientRegistrationAgg/ContractingPartyTemp.cs b/Company.Domain/TemporaryClientRegistrationAgg/ContractingPartyTemp.cs index b72758d3..e6ee8870 100644 --- a/Company.Domain/TemporaryClientRegistrationAgg/ContractingPartyTemp.cs +++ b/Company.Domain/TemporaryClientRegistrationAgg/ContractingPartyTemp.cs @@ -91,6 +91,10 @@ public class ContractingPartyTemp : EntityBase /// public string Address { get; private set; } - - + public void UpdateAddress(string state, string city, string address) + { + this.State = state; + this.City = city; + this.Address = address; + } } \ No newline at end of file diff --git a/Company.Domain/TemporaryClientRegistrationAgg/IWorkshopServicesTempRepository.cs b/Company.Domain/TemporaryClientRegistrationAgg/IWorkshopServicesTempRepository.cs new file mode 100644 index 00000000..5e66ba68 --- /dev/null +++ b/Company.Domain/TemporaryClientRegistrationAgg/IWorkshopServicesTempRepository.cs @@ -0,0 +1,8 @@ +using _0_Framework.Domain; + +namespace Company.Domain.TemporaryClientRegistrationAgg; + +public interface IWorkshopServicesTempRepository : IRepository +{ + +} \ No newline at end of file diff --git a/Company.Domain/TemporaryClientRegistrationAgg/IWorkshopTempRepository.cs b/Company.Domain/TemporaryClientRegistrationAgg/IWorkshopTempRepository.cs new file mode 100644 index 00000000..5ba19824 --- /dev/null +++ b/Company.Domain/TemporaryClientRegistrationAgg/IWorkshopTempRepository.cs @@ -0,0 +1,18 @@ +using System.Collections.Generic; +using System.Threading.Tasks; +using _0_Framework.Domain; +using CompanyManagment.App.Contracts.TemporaryClientRegistration; + +namespace Company.Domain.TemporaryClientRegistrationAgg; + +public interface IWorkshopTempRepository : IRepository +{ + /// + /// دریافت کارگاه های ذخیره شده + /// + /// + /// + Task> GetWorkshopTemp(long contractingPartyTemp); + + +} \ No newline at end of file diff --git a/Company.Domain/TemporaryClientRegistrationAgg/WorkshopServicesTemp.cs b/Company.Domain/TemporaryClientRegistrationAgg/WorkshopServicesTemp.cs new file mode 100644 index 00000000..854c3641 --- /dev/null +++ b/Company.Domain/TemporaryClientRegistrationAgg/WorkshopServicesTemp.cs @@ -0,0 +1,34 @@ +using _0_Framework.Domain; + +namespace Company.Domain.TemporaryClientRegistrationAgg; + +public class WorkshopServicesTemp : EntityBase +{ + public WorkshopServicesTemp(string serviceName, int countPerson, long workshopTempId) + { + ServiceName = serviceName; + CountPerson = countPerson; + WorkshopTempId = workshopTempId; + } + /// + /// نام سرویس + /// + public string ServiceName { get; private set; } + + /// + /// تعداد پرسنل + /// + public int CountPerson { get; private set; } + + /// + /// آی دی کارگاه موقت + /// + public long WorkshopTempId { get; private set; } + + public WorkshopTemp WorkshopTemp { get; private set; } + + public void UpdateService(int countPerson) + { + this.CountPerson = countPerson; + } +} \ No newline at end of file diff --git a/Company.Domain/TemporaryClientRegistrationAgg/WorkshopTemp.cs b/Company.Domain/TemporaryClientRegistrationAgg/WorkshopTemp.cs new file mode 100644 index 00000000..26169d8a --- /dev/null +++ b/Company.Domain/TemporaryClientRegistrationAgg/WorkshopTemp.cs @@ -0,0 +1,48 @@ +using System.Collections.Generic; +using _0_Framework.Domain; + +namespace Company.Domain.TemporaryClientRegistrationAgg; + +public class WorkshopTemp : EntityBase +{ + public WorkshopTemp(string workshopName, int countPerson, long contractingPartyTempId, double workshopServicesAmount) + { + WorkshopName = workshopName; + CountPerson = countPerson; + ContractingPartyTempId = contractingPartyTempId; + WorkshopServicesAmount = workshopServicesAmount; + } + + /// + /// نام کارگاه + /// + public string WorkshopName { get; private set; } + + /// + /// تعداد پرسنل + /// + public int CountPerson { get; private set; } + + /// + /// ای دی طرف حساب + /// + public long ContractingPartyTempId { get; private set; } + + /// + /// جمع کل مبالغ سرویس ها برای کارگاه + /// + public double WorkshopServicesAmount { get; private set; } + + public List WorkshopServicesTemps { get; private set; } + + + + public void Edit(string workshopName, int countPerson, double workshopServicesAmount) + { + this.WorkshopName = workshopName; + this.CountPerson = countPerson; + this.WorkshopServicesAmount = workshopServicesAmount; + } + + +} \ No newline at end of file diff --git a/CompanyManagment.App.Contracts/TemporaryClientRegistration/CreateWorkshopServicesTemp.cs b/CompanyManagment.App.Contracts/TemporaryClientRegistration/CreateWorkshopServicesTemp.cs new file mode 100644 index 00000000..7c85a593 --- /dev/null +++ b/CompanyManagment.App.Contracts/TemporaryClientRegistration/CreateWorkshopServicesTemp.cs @@ -0,0 +1,19 @@ +namespace CompanyManagment.App.Contracts.TemporaryClientRegistration; + +public class CreateWorkshopServicesTemp +{ + /// + /// نام سرویس + /// + public string ServiceName { get; set; } + + /// + /// تعداد پرسنل + /// + public int CountPerson { get; set; } + + /// + /// آی دی کارگاه موقت + /// + public long WorkshopTempId { get; set; } +} \ No newline at end of file diff --git a/CompanyManagment.App.Contracts/TemporaryClientRegistration/CreateWorkshopTemp.cs b/CompanyManagment.App.Contracts/TemporaryClientRegistration/CreateWorkshopTemp.cs new file mode 100644 index 00000000..9130e657 --- /dev/null +++ b/CompanyManagment.App.Contracts/TemporaryClientRegistration/CreateWorkshopTemp.cs @@ -0,0 +1,66 @@ +namespace CompanyManagment.App.Contracts.TemporaryClientRegistration; + +public class CreateWorkshopTemp +{ + /// + /// نام کارگاه + /// + public string WorkshopName { get; set; } + + /// + /// تعداد پرسنل + /// + public int CountPerson { get; set; } + + /// + /// ای دی طرف حساب + /// + public long ContractingPartyTempId { get; set; } + + /// + /// جمع کل مبالغ سرویس ها برای کارگاه + /// Double + /// + public double WorkshopServicesAmount { get; set; } + + /// + /// جمع کل مبالغ سرویس ها برای کارگاه + /// فارسی + /// + public double WorkshopServicesAmountStr { get; set; } + + + #region ServiceSelection + + /// + /// قرارداد و تصفیه + /// + public bool ContractAndCheckoutPercent { get; set; } + + /// + /// بیمه + /// + public bool InsurancePercent { get; set; } + + /// + /// حضورغباب + /// + public bool RollCallPercent { get; set; } + + /// + /// فیش غیر رسمی + /// + public bool CustomizeCheckoutPercent { get; set; } + + ///// + ///// خدمات حضوری قرداد و تصفیه + ///// + //public bool ContractAndCheckoutInPersonPercent { get; set; } + + ///// + ///// خدمات حضوری بیمه + ///// + //public bool InsuranceInPersonPercent { get; set; } + + #endregion +} \ No newline at end of file diff --git a/CompanyManagment.App.Contracts/TemporaryClientRegistration/ITemporaryClientRegistrationApplication.cs b/CompanyManagment.App.Contracts/TemporaryClientRegistration/ITemporaryClientRegistrationApplication.cs index 0bf213d1..6383ef93 100644 --- a/CompanyManagment.App.Contracts/TemporaryClientRegistration/ITemporaryClientRegistrationApplication.cs +++ b/CompanyManagment.App.Contracts/TemporaryClientRegistration/ITemporaryClientRegistrationApplication.cs @@ -1,9 +1,34 @@ -using System.Threading.Tasks; +using System.Collections.Generic; +using System.Threading.Tasks; using _0_Framework.Application; namespace CompanyManagment.App.Contracts.TemporaryClientRegistration; public interface ITemporaryClientRegistrationApplication { + /// + /// احراز هویت + /// + /// + /// + /// + /// Task> CreateContractingPartyTemp(string nationalCode, string dateOfBirth, string mobile); + + /// + /// تکمیل اطلاعات + /// + /// + /// + /// + /// + /// + Task UpdateAddress(long id, string state, string city, string address); + + /// + /// دریافت کارگاه های ذخیره شده + /// + /// + /// + Task> GetWorkshopTemp(long contractingPartyTemp); } \ No newline at end of file diff --git a/CompanyManagment.App.Contracts/TemporaryClientRegistration/WorkshopServicesTempViewModel.cs b/CompanyManagment.App.Contracts/TemporaryClientRegistration/WorkshopServicesTempViewModel.cs new file mode 100644 index 00000000..7e4ee777 --- /dev/null +++ b/CompanyManagment.App.Contracts/TemporaryClientRegistration/WorkshopServicesTempViewModel.cs @@ -0,0 +1,6 @@ +namespace CompanyManagment.App.Contracts.TemporaryClientRegistration; + +public class WorkshopServicesTempViewModel +{ + public long Id { get; set; } +} \ No newline at end of file diff --git a/CompanyManagment.App.Contracts/TemporaryClientRegistration/WorkshopTempViewModel.cs b/CompanyManagment.App.Contracts/TemporaryClientRegistration/WorkshopTempViewModel.cs new file mode 100644 index 00000000..c0bc27f2 --- /dev/null +++ b/CompanyManagment.App.Contracts/TemporaryClientRegistration/WorkshopTempViewModel.cs @@ -0,0 +1,6 @@ +namespace CompanyManagment.App.Contracts.TemporaryClientRegistration; + +public class WorkshopTempViewModel : CreateWorkshopTemp +{ + public long Id { get; set; } +} \ No newline at end of file diff --git a/CompanyManagment.Application/TemporaryClientRegistrationApplication.cs b/CompanyManagment.Application/TemporaryClientRegistrationApplication.cs index bd4174a3..a844ad88 100644 --- a/CompanyManagment.Application/TemporaryClientRegistrationApplication.cs +++ b/CompanyManagment.Application/TemporaryClientRegistrationApplication.cs @@ -1,4 +1,5 @@ -using System.Threading.Tasks; +using System.Collections.Generic; +using System.Threading.Tasks; using _0_Framework.Application; using _0_Framework.Application.UID; using Company.Domain.ContarctingPartyAgg; @@ -21,6 +22,13 @@ public class TemporaryClientRegistrationApplication : ITemporaryClientRegistrati _uidService = uidService; } + /// + /// احراز هویت + /// + /// + /// + /// + /// public async Task> CreateContractingPartyTemp(string nationalCode , string dateOfBirth, string mobile) { var op = new OperationResult(); @@ -58,6 +66,8 @@ public class TemporaryClientRegistrationApplication : ITemporaryClientRegistrati var dateOfBirthGr = dateOfBirth.ToGeorgianDateTime(); + + //اگر طرف حساب موقت قبلا ایجاد شده دیتای آن را برمیگرداند if (getExistTemp != null) { @@ -107,5 +117,28 @@ public class TemporaryClientRegistrationApplication : ITemporaryClientRegistrati return op.Succcedded(result); } + + + } + + + public async Task UpdateAddress(long id, string state, string city, string address) + { + var op = new OperationResult(); + var contractingPartyTemp = _contractingPartyTempRepository.Get(id); + + if (string.IsNullOrWhiteSpace(state) || string.IsNullOrWhiteSpace(city) || string.IsNullOrWhiteSpace(address)) + return op.Failed("اطلاعات ادرس را تکمیل کنید"); + + contractingPartyTemp.UpdateAddress(state,city,address); + await _contractingPartyTempRepository.SaveChangesAsync(); + + return op.Succcedded(); + } + + + public Task> GetWorkshopTemp(long contractingPartyTemp) + { + throw new System.NotImplementedException(); } } \ No newline at end of file diff --git a/CompanyManagment.EFCore/CompanyContext.cs b/CompanyManagment.EFCore/CompanyContext.cs index 6b895896..0a3fe5aa 100644 --- a/CompanyManagment.EFCore/CompanyContext.cs +++ b/CompanyManagment.EFCore/CompanyContext.cs @@ -193,7 +193,8 @@ public class CompanyContext : DbContext #region TemporaryClientRegisteration public DbSet ContractingPartyTemps { get; set; } - + public DbSet WorkshopTemps { get; set; } + public DbSet WorkshopServicesTemps { get; set; } #endregion public DbSet CustomizeCheckouts { get; set; } public DbSet CustomizeCheckoutTemps { get; set; } diff --git a/CompanyManagment.EFCore/Mapping/WorkshopServicesTempMapping.cs b/CompanyManagment.EFCore/Mapping/WorkshopServicesTempMapping.cs new file mode 100644 index 00000000..e406e259 --- /dev/null +++ b/CompanyManagment.EFCore/Mapping/WorkshopServicesTempMapping.cs @@ -0,0 +1,20 @@ +using Company.Domain.TemporaryClientRegistrationAgg; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Metadata.Builders; + +namespace CompanyManagment.EFCore.Mapping; + +public class WorkshopServicesTempMapping : IEntityTypeConfiguration +{ + public void Configure(EntityTypeBuilder builder) + { + builder.ToTable("WorkshopServicesTemps"); + builder.HasKey(x => x.id); + + builder.Property(x => x.ServiceName).HasMaxLength(40); + + builder.HasOne(x => x.WorkshopTemp) + .WithMany(x => x.WorkshopServicesTemps) + .HasForeignKey(x => x.WorkshopTempId); + } +} \ No newline at end of file diff --git a/CompanyManagment.EFCore/Mapping/WorkshopTempMapping.cs b/CompanyManagment.EFCore/Mapping/WorkshopTempMapping.cs new file mode 100644 index 00000000..1c5ebba6 --- /dev/null +++ b/CompanyManagment.EFCore/Mapping/WorkshopTempMapping.cs @@ -0,0 +1,20 @@ +using Company.Domain.TemporaryClientRegistrationAgg; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Metadata.Builders; + +namespace CompanyManagment.EFCore.Mapping; + +public class WorkshopTempMapping : IEntityTypeConfiguration +{ + public void Configure(EntityTypeBuilder builder) + { + builder.ToTable("WorkshopTemps"); + builder.HasKey(x => x.id); + + builder.Property(x => x.WorkshopName).HasMaxLength(255); + + builder.HasMany(x => x.WorkshopServicesTemps) + .WithOne(x => x.WorkshopTemp) + .HasForeignKey(x => x.WorkshopTempId); + } +} \ No newline at end of file diff --git a/CompanyManagment.EFCore/Repository/ContractingPartyTempRepository.cs b/CompanyManagment.EFCore/Repository/ContractingPartyTempRepository.cs index b05d35cd..195afbef 100644 --- a/CompanyManagment.EFCore/Repository/ContractingPartyTempRepository.cs +++ b/CompanyManagment.EFCore/Repository/ContractingPartyTempRepository.cs @@ -52,6 +52,7 @@ public class ContractingPartyTempRepository : RepositoryBase, IWorkshopTempRepository +{ + private readonly CompanyContext _context; + public WorkshopTempRepository(CompanyContext context) : base(context) + { + _context = context; + } + + public async Task> GetWorkshopTemp(long contractingPartyTemp) + { + var result =_context.WorkshopTemps + .Where(x => x.ContractingPartyTempId == contractingPartyTemp) + .Include(x => x.WorkshopServicesTemps) + .Select(x => new WorkshopTempViewModel + { + Id = x.id, + WorkshopName = x.WorkshopName + + }); + + return new List(); + } +} \ No newline at end of file