Browse Source

ContractAttachments

zinab_elgendy 2 days ago
parent
commit
c27d62358d
28 changed files with 6192 additions and 24 deletions
  1. 8 1
      MTWorkHR.API/Controllers/CompanyController.cs
  2. 31 2
      MTWorkHR.API/Controllers/ContractController.cs
  3. 8 0
      MTWorkHR.API/Controllers/UserController.cs
  4. 1 1
      MTWorkHR.API/Program.cs
  5. 2 0
      MTWorkHR.Application/ApplicationServiceRegistration.cs
  6. 2 1
      MTWorkHR.Application/Dtos/Contract/ContractTaskAttachmentDto.cs
  7. 2 0
      MTWorkHR.Application/Dtos/Contract/ProjectStageAttachmentDto.cs
  8. 2 0
      MTWorkHR.Application/Dtos/User/CompanyDto.cs
  9. 25 16
      MTWorkHR.Application/Services/Base/BlobFileService.cs
  10. 93 0
      MTWorkHR.Application/Services/Contract/ContractTaskAttachmentService.cs
  11. 91 0
      MTWorkHR.Application/Services/Contract/ProjectStageAttachmentService.cs
  12. 1 0
      MTWorkHR.Application/Services/Interfaces/ICompanyService.cs
  13. 12 0
      MTWorkHR.Application/Services/Interfaces/IContractTaskAttachmentService.cs
  14. 12 0
      MTWorkHR.Application/Services/Interfaces/IProjectStageAttachmentService.cs
  15. 1 0
      MTWorkHR.Application/Services/Interfaces/IUserService.cs
  16. 8 0
      MTWorkHR.Application/Services/User/CompanyService.cs
  17. 11 1
      MTWorkHR.Application/Services/User/UserService.cs
  18. 1 0
      MTWorkHR.Core/Entities/User/Company.cs
  19. 15 0
      MTWorkHR.Core/IRepositories/Contract/IContractTaskAttachmentRepository.cs
  20. 15 0
      MTWorkHR.Core/IRepositories/Contract/IProjectStageAttachmentRepository.cs
  21. 3 0
      MTWorkHR.Core/IUnitOfWork/IUnitOfWork.cs
  22. 3 1
      MTWorkHR.Infrastructure/InfrastructureServiceRegistration.cs
  23. 5773 0
      MTWorkHR.Infrastructure/Migrations/20241218150942_altrContractAttach.Designer.cs
  24. 29 0
      MTWorkHR.Infrastructure/Migrations/20241218150942_altrContractAttach.cs
  25. 3 0
      MTWorkHR.Infrastructure/Migrations/HRDataContextModelSnapshot.cs
  26. 17 0
      MTWorkHR.Infrastructure/Repositories/Contract/ContractTaskAttachmentRepository.cs
  27. 17 0
      MTWorkHR.Infrastructure/Repositories/Contract/ProjectStageAttachmentRepository.cs
  28. 6 1
      MTWorkHR.Infrastructure/UnitOfWork/UnitOfWork.cs

+ 8 - 1
MTWorkHR.API/Controllers/CompanyController.cs

@@ -61,7 +61,14 @@ namespace MTWorkHR.API.Controllers
         {
             await _companyService.Delete(id);
         }
+        [HttpDelete("Suspend")]
+        [ProducesResponseType(StatusCodes.Status200OK)]
+
+        public async Task Suspend([FromQuery] long id)
+        {
+            await _companyService.Suspend(id);
+        }
+
 
-       
     }
 }

+ 31 - 2
MTWorkHR.API/Controllers/ContractController.cs

@@ -15,9 +15,14 @@ namespace MTWorkHR.API.Controllers
     public class ContractController : ControllerBase
     {
         private readonly IContractService _ContractService;
-        public ContractController(IContractService UserContractService)
+        private readonly IContractTaskAttachmentService _ContractTaskAttachmentService;
+        private readonly IProjectStageAttachmentService _ProjectStageAttachmentService;
+        private readonly IFileService _fileService;
+
+        public ContractController(IContractService UserContractService, IFileService fileService)
         {
-            this._ContractService = UserContractService;
+            _ContractService = UserContractService;
+            _fileService = fileService;
         }
         [HttpGet("GetAll")]
         [ProducesResponseType(StatusCodes.Status200OK)]
@@ -68,5 +73,29 @@ namespace MTWorkHR.API.Controllers
             return await _ContractService.ChangeStatus(input.ContractId, input.StatusId);
         }
 
+        [HttpPost("UploadAttachment")]
+        [ProducesResponseType(StatusCodes.Status200OK)]
+        [Consumes("multipart/form-data")]
+        public async Task<ActionResult<string>> UploadAttachment(IFormFile input)
+        {
+            return await _fileService.UploadFile(input);
+        }
+
+        //[HttpPost("CreateTaskAttachment")]
+        //[ProducesResponseType(StatusCodes.Status200OK)]
+        //[Consumes("multipart/form-data")]
+        //public async Task<ActionResult<AttachmentDto>> CreateTaskAttachment([FromForm] AttachmentDto input)
+        //{
+        //    return await _ContractTaskAttachmentService.Create(input);
+        //}
+
+        //[HttpPost("CreateProjectAttachment")]
+        //[ProducesResponseType(StatusCodes.Status200OK)]
+        //[Consumes("multipart/form-data")]
+        //public async Task<ActionResult<AttachmentDto>> CreateProjectAttachment([FromForm] AttachmentDto input)
+        //{
+        //    return await _ProjectStageAttachmentService.Create(input);
+        //}
+
     }
 }

+ 8 - 0
MTWorkHR.API/Controllers/UserController.cs

@@ -72,6 +72,14 @@ namespace MTWorkHR.API.Controllers
             await _userService.Delete(id);
         }
 
+        [HttpDelete("Suspend")]
+        [ProducesResponseType(StatusCodes.Status200OK)]
+
+        public async Task Suspend([FromQuery] string id)
+        {
+            await _userService.Suspend(id);
+        }
+
         [HttpPost("ResetPassword")]
         [ProducesResponseType(StatusCodes.Status200OK)]
         public async Task<bool> ResetPassword([FromBody] ResetPasswordDto input)

+ 1 - 1
MTWorkHR.API/Program.cs

@@ -38,7 +38,7 @@ var config = new AppSettingsConfiguration();
 // Add services to the container.
 builder.Services.AddDbContext<HRDataContext>(options =>
 {
-    options.UseSqlServer(config.ConnectionStrings.MTWorkHRConnectionString);
+    options.UseSqlServer(config.ConnectionStrings.LocalConnectionString);
     //  options.UseSqlServer(builder.Configuration.GetSection("ConnectionStrings:MTWorkHRConnectionString").Value);
 });
 

+ 2 - 0
MTWorkHR.Application/ApplicationServiceRegistration.cs

@@ -36,6 +36,8 @@ namespace MTWorkHR.Application
             services.AddScoped<ILookupService, LookupService>();
             services.AddScoped<ICompanyService, CompanyService>();
             services.AddScoped<IContractService, ContractService>();
+            services.AddScoped<IContractTaskAttachmentService, ContractTaskAttachmentService>();
+            services.AddScoped<IProjectStageAttachmentService, ProjectStageAttachmentService>();
             services.AddScoped<IOTPService, OTPService>();
             services.AddScoped<ILogService<UserLog>, LogService<UserLog>>();
 

+ 2 - 1
MTWorkHR.Application/Dtos/Contract/ContractTaskAttachmentDto.cs

@@ -1,6 +1,7 @@
 using MTWorkHR.Core.Entities.Base;
 using System.ComponentModel.DataAnnotations.Schema;
 using System.ComponentModel.DataAnnotations;
+using Microsoft.AspNetCore.Http;
 
 
 namespace MTWorkHR.Application.Models
@@ -19,7 +20,7 @@ namespace MTWorkHR.Application.Models
 
         [MaxLength(250)]
         public string? OriginalName { get; set; }
-
+        public IFormFile? FileData { get; set; }
         public byte[] Content { get; set; }
         public string? FilePath { get; set; }
         public string? ContentType { get; set; }

+ 2 - 0
MTWorkHR.Application/Dtos/Contract/ProjectStageAttachmentDto.cs

@@ -1,6 +1,7 @@
 using MTWorkHR.Core.Entities.Base;
 using System.ComponentModel.DataAnnotations.Schema;
 using System.ComponentModel.DataAnnotations;
+using Microsoft.AspNetCore.Http;
 
 
 namespace MTWorkHR.Application.Models
@@ -19,6 +20,7 @@ namespace MTWorkHR.Application.Models
 
         [MaxLength(250)]
         public string? OriginalName { get; set; }
+        public IFormFile? FileData { get; set; }
 
         public byte[] Content { get; set; }
         public string? FilePath { get; set; }

+ 2 - 0
MTWorkHR.Application/Dtos/User/CompanyDto.cs

@@ -29,6 +29,8 @@ namespace MTWorkHR.Application.Models
         public IFormFile? ExperienceCertificateAttach { get; set; }
         public IFormFile? IdAttach { get; set; }
         public string? CreateUser { get; set; }
+        public bool IsSuspended { get; set; }
+
 
     }
 }

+ 25 - 16
MTWorkHR.Application/Services/Base/BlobFileService.cs

@@ -32,9 +32,13 @@ namespace MTWorkHR.Application.Services
             try
             {
                 var blobClient = _containerClient.GetBlobClient(file.FileName);
-                var status = await blobClient.UploadAsync(file.OpenReadStream(), true);
-                //if(status.Value == "201")
-                return blobClient.Uri.AbsoluteUri;
+                if (blobClient != null)
+                {
+                    var status = await blobClient.UploadAsync(file.OpenReadStream(), true);
+                    //if(status.Value == "201")
+                    return blobClient.Uri.AbsoluteUri;
+                }else
+                    return "";
             }
             catch (Exception ex)
             {
@@ -46,22 +50,27 @@ namespace MTWorkHR.Application.Services
             try
             {
                 var blobClient = _containerClient.GetBlobClient(file.FileName);
-                //var stream = file.FileData.OpenReadStream();
-                using (Stream fs = file.FileData.OpenReadStream())
+                if(blobClient != null)
                 {
-                    var status = await blobClient.UploadAsync(fs, true);
-                    fs.Position = 0;
-                    using (BinaryReader br = new BinaryReader(fs))
+                    //var stream = file.FileData.OpenReadStream();
+                    using (Stream fs = file.FileData.OpenReadStream())
                     {
-                        byte[] bytes = br.ReadBytes((Int32)fs.Length);
-                        var Headers = file.FileData.Headers;
-                        file.Content = bytes;
-                        file.ContentType = file.FileData.ContentType;
-                        file.FilePath = blobClient.Uri.AbsoluteUri;
+                        var status = await blobClient.UploadAsync(fs, true);
+                        fs.Position = 0;
+                        using (BinaryReader br = new BinaryReader(fs))
+                        {
+                            byte[] bytes = br.ReadBytes((Int32)fs.Length);
+                            var Headers = file.FileData.Headers;
+                            file.Content = bytes;
+                            file.ContentType = file.FileData.ContentType;
+                            file.FilePath = blobClient.Uri.AbsoluteUri;
+                        }
                     }
-                }
-                //if(status.Value == "201")
-                return blobClient.Uri.AbsoluteUri;
+                    //if(status.Value == "201")
+                    return blobClient.Uri.AbsoluteUri;
+                }else
+                    return "";
+
             }
             catch (Exception ex)
             {

+ 93 - 0
MTWorkHR.Application/Services/Contract/ContractTaskAttachmentService.cs

@@ -0,0 +1,93 @@
+
+using MTWorkHR.Application.Models;
+using MTWorkHR.Core.UnitOfWork;
+using MTWorkHR.Application.Services.Interfaces;
+using MTWorkHR.Core.Entities;
+using Microsoft.AspNetCore.Identity;
+using MTWorkHR.Application.Mapper;
+using MTWorkHR.Core.Global;
+using MTWorkHR.Infrastructure.Entities;
+using MTWorkHR.Infrastructure.Repositories;
+using MTWorkHR.Infrastructure.UnitOfWorks;
+using MTWorkHR.Core.IRepositories.Base;
+using Microsoft.AspNetCore.Http;
+using System.IO;
+
+namespace MTWorkHR.Application.Services
+{
+    public class ContractTaskAttachmentService : BaseService<ContractTaskAttachment, ContractTaskAttachmentDto, ContractTaskAttachmentDto>, IContractTaskAttachmentService
+    {
+        private readonly IUnitOfWork _unitOfWork;
+        //private readonly AppSettingsConfiguration _configuration;
+        //private readonly GlobalInfo _globalInfo;
+        private readonly IFileService _fileService;
+
+        public ContractTaskAttachmentService(IUnitOfWork unitOfWork, IFileService fileService) : base(unitOfWork)
+        {
+            _unitOfWork = unitOfWork;
+            _fileService = fileService;
+        }
+
+
+        public override async Task<ContractTaskAttachmentDto> GetById(long id)
+        {
+            var entity = await _unitOfWork.ContractTaskAttachment.GetByIdAsync(id);
+            var response = MapperObject.Mapper.Map<ContractTaskAttachmentDto>(entity);
+            return response;
+        }
+
+        public override async Task<ContractTaskAttachmentDto> Create(ContractTaskAttachmentDto input)
+        {
+            if (input.FileData != null)
+            {
+               // input.FilePath = await _fileService.UploadFile(input.FileData);
+                input.OriginalName = input.FileData.FileName;
+                List<AttachmentDto> attachs = new List<AttachmentDto>();
+                attachs.Add(new AttachmentDto {FileData = input.FileData, OriginalName = input.OriginalName, FileName = input.FileData.FileName });
+                _fileService.CopyFileToCloud(ref attachs);
+
+            }
+            
+            var entity = MapperObject.Mapper.Map<ContractTaskAttachment>(input);
+            if (entity is null)
+            {
+                throw new AppException(ExceptionEnum.MapperIssue);
+            }
+
+            var task = await _unitOfWork.ContractTaskAttachment.AddAsync(entity);
+            await _unitOfWork.CompleteAsync();
+
+            var response = MapperObject.Mapper.Map<ContractTaskAttachmentDto>(task);
+            //using (var stream = new MemoryStream(attach.Content))
+            //{
+            //    var file = new FormFile(stream, 0, stream.Length, Path.GetFileNameWithoutExtension(attach.FileName), attach.FileName)
+            //    {
+            //        Headers = new HeaderDictionary(),
+            //        ContentType = attach.ContentType,
+            //    };
+
+            //    System.Net.Mime.ContentDisposition cd = new System.Net.Mime.ContentDisposition
+            //    {
+            //        FileName = file.FileName
+            //    };
+            //    file.ContentDisposition = cd.ToString();
+            //}
+            return response;
+        }
+
+
+        //public override async Task<ContractTaskAttachmentDto> Update(ContractTaskAttachmentDto input)
+        //{
+        //    var entitiy = await _unitOfWork.ContractTaskAttachment.GetByIdAsync(input.Id);
+
+        //    if (entitiy == null)
+        //        throw new AppException(ExceptionEnum.RecordNotExist);
+
+        //    MapperObject.Mapper.Map(input, entitiy, typeof(ContractTaskAttachmentDto), typeof(ContractTaskAttachment));
+
+        //    await _unitOfWork.CompleteAsync();
+
+        //    return input;
+        //}
+    }
+}

+ 91 - 0
MTWorkHR.Application/Services/Contract/ProjectStageAttachmentService.cs

@@ -0,0 +1,91 @@
+
+using MTWorkHR.Application.Models;
+using MTWorkHR.Core.UnitOfWork;
+using MTWorkHR.Application.Services.Interfaces;
+using MTWorkHR.Core.Entities;
+using Microsoft.AspNetCore.Identity;
+using MTWorkHR.Application.Mapper;
+using MTWorkHR.Core.Global;
+using MTWorkHR.Infrastructure.Entities;
+using MTWorkHR.Infrastructure.Repositories;
+using MTWorkHR.Infrastructure.UnitOfWorks;
+using MTWorkHR.Core.IRepositories.Base;
+using Microsoft.AspNetCore.Http;
+using System.IO;
+
+namespace MTWorkHR.Application.Services
+{
+    public class ProjectStageAttachmentService : BaseService<ProjectStageAttachment, ProjectStageAttachmentDto, ProjectStageAttachmentDto>, IProjectStageAttachmentService
+    {
+        private readonly IUnitOfWork _unitOfWork;
+        private readonly IFileService _fileService;
+
+        public ProjectStageAttachmentService(IUnitOfWork unitOfWork, IFileService fileService) : base(unitOfWork)
+        {
+            _unitOfWork = unitOfWork;
+            _fileService = fileService;
+        }
+
+
+        public override async Task<ProjectStageAttachmentDto> GetById(long id)
+        {
+            var entity = await _unitOfWork.ContractTaskAttachment.GetByIdAsync(id);
+            var response = MapperObject.Mapper.Map<ProjectStageAttachmentDto>(entity);
+            return response;
+        }
+
+        public override async Task<ProjectStageAttachmentDto> Create(ProjectStageAttachmentDto input)
+        {
+            if (input.FileData != null)
+            {
+               // input.FilePath = await _fileService.UploadFile(input.FileData);
+                input.OriginalName = input.FileData.FileName;
+                List<AttachmentDto> attachs = new List<AttachmentDto>();
+                attachs.Add(new AttachmentDto { FileData = input.FileData, OriginalName = input.OriginalName, FileName = input.FileData.FileName });
+                _fileService.CopyFileToCloud(ref attachs);
+
+            }
+            
+            var entity = MapperObject.Mapper.Map<ContractTaskAttachment>(input);
+            if (entity is null)
+            {
+                throw new AppException(ExceptionEnum.MapperIssue);
+            }
+
+            var task = await _unitOfWork.ContractTaskAttachment.AddAsync(entity);
+            await _unitOfWork.CompleteAsync();
+
+            var response = MapperObject.Mapper.Map<ProjectStageAttachmentDto>(task);
+            //using (var stream = new MemoryStream(attach.Content))
+            //{
+            //    var file = new FormFile(stream, 0, stream.Length, Path.GetFileNameWithoutExtension(attach.FileName), attach.FileName)
+            //    {
+            //        Headers = new HeaderDictionary(),
+            //        ContentType = attach.ContentType,
+            //    };
+
+            //    System.Net.Mime.ContentDisposition cd = new System.Net.Mime.ContentDisposition
+            //    {
+            //        FileName = file.FileName
+            //    };
+            //    file.ContentDisposition = cd.ToString();
+            //}
+            return response;
+        }
+
+
+        //public override async Task<ProjectStageAttachmentDto> Update(ProjectStageAttachmentDto input)
+        //{
+        //    var entitiy = await _unitOfWork.ContractTaskAttachment.GetByIdAsync(input.Id);
+
+        //    if (entitiy == null)
+        //        throw new AppException(ExceptionEnum.RecordNotExist);
+
+        //    MapperObject.Mapper.Map(input, entitiy, typeof(ProjectStageAttachmentDto), typeof(ContractTaskAttachment));
+
+        //    await _unitOfWork.CompleteAsync();
+
+        //    return input;
+        //}
+    }
+}

+ 1 - 0
MTWorkHR.Application/Services/Interfaces/ICompanyService.cs

@@ -15,6 +15,7 @@ namespace MTWorkHR.Application.Services.Interfaces
         Task<List<CompanyDto>> GetAllCompanies();
         Task<CompanyDto> GetById();
         Task<CompanyDto> GetById(long companyId);
+        Task Suspend(long companyId);
 
     }
 }

+ 12 - 0
MTWorkHR.Application/Services/Interfaces/IContractTaskAttachmentService.cs

@@ -0,0 +1,12 @@
+
+using MTWorkHR.Application.Models;
+using MTWorkHR.Core.Entities.Base;
+using MTWorkHR.Core.Entities;
+using System.Threading.Tasks;
+
+namespace MTWorkHR.Application.Services.Interfaces
+{
+    public interface IContractTaskAttachmentService : IService<ContractTaskAttachment, ContractTaskAttachmentDto, ContractTaskAttachmentDto>
+    {
+    }
+}

+ 12 - 0
MTWorkHR.Application/Services/Interfaces/IProjectStageAttachmentService.cs

@@ -0,0 +1,12 @@
+
+using MTWorkHR.Application.Models;
+using MTWorkHR.Core.Entities.Base;
+using MTWorkHR.Core.Entities;
+using System.Threading.Tasks;
+
+namespace MTWorkHR.Application.Services.Interfaces
+{
+    public interface IProjectStageAttachmentService : IService<ProjectStageAttachment, ProjectStageAttachmentDto, ProjectStageAttachmentDto>
+    {
+    }
+}

+ 1 - 0
MTWorkHR.Application/Services/Interfaces/IUserService.cs

@@ -34,5 +34,6 @@ namespace MTWorkHR.Application.Identity
         Task<UserDto> GetUserWithAttachmentById(string id);
         Task<string> GetProfileImage(string userId);
         Task<bool> Update(string userId, long companyId);
+        Task Suspend(string id);
     }
 }

+ 8 - 0
MTWorkHR.Application/Services/User/CompanyService.cs

@@ -273,5 +273,13 @@ namespace MTWorkHR.Application.Services
             await _unitOfWork.Company.DeleteAsync(entity);
 
         }
+
+        public async Task Suspend(long id)
+        {
+            var entity = await _unitOfWork.Company.GetByIdAsync(id);
+            await _userService.Suspend(entity.UserId); // delete user first
+            entity.IsSuspended = true;
+            await _unitOfWork.CompleteAsync();
+        }
     }
 }

+ 11 - 1
MTWorkHR.Application/Services/User/UserService.cs

@@ -194,7 +194,7 @@ namespace MTWorkHR.Application.Services
                 .Include(u => u.University)
                 .Include(u => u.Industry)
                 .Include(u => u.Country)
-                .Where(u => _globalInfo.CompanyId == null || u.CompanyId != _globalInfo.CompanyId);
+                .Where(u => !u.IsDeleted && !u.IsStopped && ( _globalInfo.CompanyId == null || u.CompanyId != _globalInfo.CompanyId));
 
             var filter = PagingInputDto.Filter?.Trim();
 
@@ -294,6 +294,16 @@ namespace MTWorkHR.Application.Services
                 await _userManager.UpdateAsync(user);
             }
         }
+        public async Task Suspend(string id)
+        {
+            var user = await _userManager.FindByIdAsync(id);
+            if (user != null)
+            {
+                user.IsStopped = true;
+
+                await _userManager.UpdateAsync(user);
+            }
+        }
 
 
         public async Task<UserDto> Create(UserDto input)

+ 1 - 0
MTWorkHR.Core/Entities/User/Company.cs

@@ -19,6 +19,7 @@ namespace MTWorkHR.Core.Entities
         public string PhoneNumber { get; set; }
         public string Address { get; set; }
         public string Email { get; set; }
+        public bool IsSuspended { get; set; }
 
         public long? CountryId { get; set; }
         [ForeignKey("CountryId")]

+ 15 - 0
MTWorkHR.Core/IRepositories/Contract/IContractTaskAttachmentRepository.cs

@@ -0,0 +1,15 @@
+using MTWorkHR.Core.Entities;
+using MTWorkHR.Core.IDto;
+using MTWorkHR.Core.IRepositories.Base;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace MTWorkHR.Core.IRepositories
+{
+    public interface IContractTaskAttachmentRepository : IRepository<ContractTaskAttachment>
+    {
+    }
+}

+ 15 - 0
MTWorkHR.Core/IRepositories/Contract/IProjectStageAttachmentRepository.cs

@@ -0,0 +1,15 @@
+using MTWorkHR.Core.Entities;
+using MTWorkHR.Core.IDto;
+using MTWorkHR.Core.IRepositories.Base;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace MTWorkHR.Core.IRepositories
+{
+    public interface IProjectStageAttachmentRepository : IRepository<ProjectStageAttachment>
+    {
+    }
+}

+ 3 - 0
MTWorkHR.Core/IUnitOfWork/IUnitOfWork.cs

@@ -37,6 +37,9 @@ namespace MTWorkHR.Core.UnitOfWork
 
         IChatMessageRepository ChatMessage { get; }
         IContractRepository Contract { get; }
+        IContractTaskAttachmentRepository ContractTaskAttachment { get; }
+        IProjectStageAttachmentRepository ProjectStageAttachment { get; }
+
         IHubConnectionRepository HubConnection { get; }
 
         Task<int> CompleteAsync();

+ 3 - 1
MTWorkHR.Infrastructure/InfrastructureServiceRegistration.cs

@@ -32,7 +32,7 @@ namespace MTWorkHR.Infrastructure
             
             services.AddDbContext<HRDataContext>(options =>
                 options.UseSqlServer(
-                    config.ConnectionStrings.MTWorkHRConnectionString  //configuration.GetSection("ConnectionString:MTWorkHRConnectionString").Value
+                    config.ConnectionStrings.LocalConnectionString  //configuration.GetSection("ConnectionString:MTWorkHRConnectionString").Value
                     ));
            
             services.AddIdentity<ApplicationUser, ApplicationRole>().AddEntityFrameworkStores<HRDataContext>().AddDefaultTokenProviders();
@@ -104,6 +104,8 @@ namespace MTWorkHR.Infrastructure
             services.AddScoped(typeof(IProjectTeamRepository), typeof(ProjectTeamRepository));
             services.AddScoped(typeof(IChatMessageRepository), typeof(ChatMessageRepository));
             services.AddScoped(typeof(IContractRepository), typeof(ContractRepository));
+            services.AddScoped(typeof(IContractTaskAttachmentRepository), typeof(ContractTaskAttachmentRepository));
+            services.AddScoped(typeof(IProjectStageAttachmentRepository), typeof(ProjectStageAttachmentRepository));
 
             services.AddScoped(typeof(IHubConnectionRepository), typeof(HubConnectionRepository));
             

File diff suppressed because it is too large
+ 5773 - 0
MTWorkHR.Infrastructure/Migrations/20241218150942_altrContractAttach.Designer.cs


+ 29 - 0
MTWorkHR.Infrastructure/Migrations/20241218150942_altrContractAttach.cs

@@ -0,0 +1,29 @@
+using Microsoft.EntityFrameworkCore.Migrations;
+
+#nullable disable
+
+namespace MTWorkHR.Infrastructure.Migrations
+{
+    /// <inheritdoc />
+    public partial class altrContractAttach : Migration
+    {
+        /// <inheritdoc />
+        protected override void Up(MigrationBuilder migrationBuilder)
+        {
+            migrationBuilder.AddColumn<bool>(
+                name: "IsSuspended",
+                table: "Companies",
+                type: "bit",
+                nullable: false,
+                defaultValue: false);
+        }
+
+        /// <inheritdoc />
+        protected override void Down(MigrationBuilder migrationBuilder)
+        {
+            migrationBuilder.DropColumn(
+                name: "IsSuspended",
+                table: "Companies");
+        }
+    }
+}

+ 3 - 0
MTWorkHR.Infrastructure/Migrations/HRDataContextModelSnapshot.cs

@@ -507,6 +507,9 @@ namespace MTWorkHR.Infrastructure.Migrations
                         .HasColumnType("bit")
                         .HasColumnOrder(7);
 
+                    b.Property<bool>("IsSuspended")
+                        .HasColumnType("bit");
+
                     b.Property<string>("PhoneNumber")
                         .IsRequired()
                         .HasColumnType("nvarchar(max)");

+ 17 - 0
MTWorkHR.Infrastructure/Repositories/Contract/ContractTaskAttachmentRepository.cs

@@ -0,0 +1,17 @@
+using Microsoft.EntityFrameworkCore;
+using MTWorkHR.Core.Entities;
+using MTWorkHR.Core.IDto;
+using MTWorkHR.Infrastructure.Entities;
+using MTWorkHR.Infrastructure.DBContext;
+using MTWorkHR.Core.IRepositories;
+
+namespace MTWorkHR.Infrastructure.Repositories
+{
+    public class ContractTaskAttachmentRepository : Repository<ContractTaskAttachment>, IContractTaskAttachmentRepository
+    {
+        public ContractTaskAttachmentRepository(HRDataContext context) : base(context)
+        {
+        }
+
+    }
+}

+ 17 - 0
MTWorkHR.Infrastructure/Repositories/Contract/ProjectStageAttachmentRepository.cs

@@ -0,0 +1,17 @@
+using Microsoft.EntityFrameworkCore;
+using MTWorkHR.Core.Entities;
+using MTWorkHR.Core.IDto;
+using MTWorkHR.Infrastructure.Entities;
+using MTWorkHR.Infrastructure.DBContext;
+using MTWorkHR.Core.IRepositories;
+
+namespace MTWorkHR.Infrastructure.Repositories
+{
+    public class ProjectStageAttachmentRepository : Repository<ProjectStageAttachment>, IProjectStageAttachmentRepository
+    {
+        public ProjectStageAttachmentRepository(HRDataContext context) : base(context)
+        {
+        }
+
+    }
+}

+ 6 - 1
MTWorkHR.Infrastructure/UnitOfWork/UnitOfWork.cs

@@ -41,7 +41,8 @@ namespace MTWorkHR.Infrastructure.UnitOfWorks
         public IChatMessageRepository ChatMessage { get; }
         public IHubConnectionRepository HubConnection { get; }
         public IContractRepository Contract{ get; }
-
+        public IContractTaskAttachmentRepository ContractTaskAttachment { get; }
+        public IProjectStageAttachmentRepository ProjectStageAttachment { get; }
         public UnitOfWork(HRDataContext _context
             , IPermissionRepository permission
             , ICompanyRepository company
@@ -69,6 +70,8 @@ namespace MTWorkHR.Infrastructure.UnitOfWorks
             , IProjectTeamRepository projectTeam
             , IChatMessageRepository chatMessage
             , IContractRepository contract
+            , IContractTaskAttachmentRepository contractTaskAttachment
+            , IProjectStageAttachmentRepository projectStageAttachment
             , IHubConnectionRepository connection
 
             )
@@ -101,6 +104,8 @@ namespace MTWorkHR.Infrastructure.UnitOfWorks
             ChatMessage = chatMessage;
             Contract = contract;
             HubConnection = connection;
+            ContractTaskAttachment = contractTaskAttachment;
+            ProjectStageAttachment = projectStageAttachment;
         }
 
         public async Task<int> CompleteAsync()