2 Commits 2bb9c48fe3 ... a1ba1df818

Author SHA1 Message Date
  zinab_elgendy a1ba1df818 remove AttachmentType from contract 1 day ago
  zinab_elgendy c27d62358d ContractAttachments 2 days ago
32 changed files with 12058 additions and 61 deletions
  1. 35 0
      MTWorkHR.API/Controllers/AttachmentController.cs
  2. 8 1
      MTWorkHR.API/Controllers/CompanyController.cs
  3. 31 2
      MTWorkHR.API/Controllers/ContractController.cs
  4. 8 0
      MTWorkHR.API/Controllers/UserController.cs
  5. 2 0
      MTWorkHR.Application/ApplicationServiceRegistration.cs
  6. 4 6
      MTWorkHR.Application/Dtos/Contract/ContractTaskAttachmentDto.cs
  7. 3 4
      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 3
      MTWorkHR.Core/Entities/Contract/ContractTaskAttachment.cs
  19. 0 3
      MTWorkHR.Core/Entities/Contract/ProjectStageAttachment.cs
  20. 1 0
      MTWorkHR.Core/Entities/User/Company.cs
  21. 15 0
      MTWorkHR.Core/IRepositories/Contract/IContractTaskAttachmentRepository.cs
  22. 15 0
      MTWorkHR.Core/IRepositories/Contract/IProjectStageAttachmentRepository.cs
  23. 3 0
      MTWorkHR.Core/IUnitOfWork/IUnitOfWork.cs
  24. 2 0
      MTWorkHR.Infrastructure/InfrastructureServiceRegistration.cs
  25. 5773 0
      MTWorkHR.Infrastructure/Migrations/20241218150942_altrContractAttach.Designer.cs
  26. 29 0
      MTWorkHR.Infrastructure/Migrations/20241218150942_altrContractAttach.cs
  27. 5749 0
      MTWorkHR.Infrastructure/Migrations/20241224101338_altrContracyAttachs.Designer.cs
  28. 80 0
      MTWorkHR.Infrastructure/Migrations/20241224101338_altrContracyAttachs.cs
  29. 3 24
      MTWorkHR.Infrastructure/Migrations/HRDataContextModelSnapshot.cs
  30. 17 0
      MTWorkHR.Infrastructure/Repositories/Contract/ContractTaskAttachmentRepository.cs
  31. 17 0
      MTWorkHR.Infrastructure/Repositories/Contract/ProjectStageAttachmentRepository.cs
  32. 6 1
      MTWorkHR.Infrastructure/UnitOfWork/UnitOfWork.cs

+ 35 - 0
MTWorkHR.API/Controllers/AttachmentController.cs

@@ -0,0 +1,35 @@
+using Microsoft.AspNetCore.Authorization;
+
+using Microsoft.AspNetCore.Http;
+using Microsoft.AspNetCore.Mvc;
+using MTWorkHR.Application.Filters;
+using MTWorkHR.Application.Models;
+using MTWorkHR.Application.Services;
+using MTWorkHR.Application.Services.Interfaces;
+
+namespace MTWorkHR.API.Controllers
+{
+    [Route("api/[controller]")]
+    [ApiController]
+    [AppAuthorize]
+    public class AttachmentController : ControllerBase
+    {
+        private readonly IFileService _fileService;
+
+        public AttachmentController(IFileService fileService)
+        {
+            _fileService = fileService;
+        }
+        
+
+        [HttpPost("Upload")]
+        [ProducesResponseType(StatusCodes.Status200OK)]
+        [Consumes("multipart/form-data")]
+        public async Task<ActionResult<string>> Upload(IFormFile input)
+        {
+            return await _fileService.UploadFile(input);
+        }
+
+
+    }
+}

+ 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)

+ 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>>();
 

+ 4 - 6
MTWorkHR.Application/Dtos/Contract/ContractTaskAttachmentDto.cs

@@ -1,26 +1,24 @@
 using MTWorkHR.Core.Entities.Base;
 using System.ComponentModel.DataAnnotations.Schema;
 using System.ComponentModel.DataAnnotations;
+using Microsoft.AspNetCore.Http;
 
 
 namespace MTWorkHR.Application.Models
 {
     public class ContractTaskAttachmentDto : EntityDto
     {
-        public long ContractTaskId { get; set; }
+        public long ContractTaskId { get; set; } = 0;
 
         public long? AttachmentTypeId { get; set; }
 
-        [ForeignKey("AttachmentTypeId")]
-        public AttachmentType AttachmentType { get; set; }
-
+     
         [MaxLength(250)]
         public string? FileName { get; set; }
 
         [MaxLength(250)]
         public string? OriginalName { get; set; }
-
-        public byte[] Content { get; set; }
+        public IFormFile? FileData { get; set; }
         public string? FilePath { get; set; }
         public string? ContentType { get; set; }
     }

+ 3 - 4
MTWorkHR.Application/Dtos/Contract/ProjectStageAttachmentDto.cs

@@ -1,26 +1,25 @@
 using MTWorkHR.Core.Entities.Base;
 using System.ComponentModel.DataAnnotations.Schema;
 using System.ComponentModel.DataAnnotations;
+using Microsoft.AspNetCore.Http;
 
 
 namespace MTWorkHR.Application.Models
 {
     public class ProjectStageAttachmentDto : EntityDto
     {
-        public long ProjectStageId { get; set; }
+        public long ProjectStageId { get; set; } = 0;
 
         public long? AttachmentTypeId { get; set; }
 
-        [ForeignKey("AttachmentTypeId")]
-        public AttachmentType AttachmentType { get; set; }
 
         [MaxLength(250)]
         public string? FileName { get; set; }
 
         [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/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 - 3
MTWorkHR.Core/Entities/Contract/ContractTaskAttachment.cs

@@ -13,8 +13,7 @@ namespace MTWorkHR.Core.Entities
         public ContractTask ContractTask { get; set; }
         public long? AttachmentTypeId { get; set; }
 
-        [ForeignKey("AttachmentTypeId")]
-        public AttachmentType AttachmentType { get; set; }
+       
 
         [MaxLength(250)]
         public string? FileName { get; set; }
@@ -22,7 +21,6 @@ namespace MTWorkHR.Core.Entities
         [MaxLength(250)]
         public string? OriginalName { get; set; }
 
-        public byte[] Content { get; set; }
         public string? FilePath { get; set; }
         public string? ContentType { get; set; }
     }

+ 0 - 3
MTWorkHR.Core/Entities/Contract/ProjectStageAttachment.cs

@@ -13,8 +13,6 @@ namespace MTWorkHR.Core.Entities
         public ProjectStage ProjectStage { get; set; }
         public long? AttachmentTypeId { get; set; }
 
-        [ForeignKey("AttachmentTypeId")]
-        public AttachmentType AttachmentType { get; set; }
 
         [MaxLength(250)]
         public string? FileName { get; set; }
@@ -22,7 +20,6 @@ namespace MTWorkHR.Core.Entities
         [MaxLength(250)]
         public string? OriginalName { get; set; }
 
-        public byte[] Content { get; set; }
         public string? FilePath { get; set; }
         public string? ContentType { get; set; }
     }

+ 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();

+ 2 - 0
MTWorkHR.Infrastructure/InfrastructureServiceRegistration.cs

@@ -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");
+        }
+    }
+}

File diff suppressed because it is too large
+ 5749 - 0
MTWorkHR.Infrastructure/Migrations/20241224101338_altrContracyAttachs.Designer.cs


+ 80 - 0
MTWorkHR.Infrastructure/Migrations/20241224101338_altrContracyAttachs.cs

@@ -0,0 +1,80 @@
+using Microsoft.EntityFrameworkCore.Migrations;
+
+#nullable disable
+
+namespace MTWorkHR.Infrastructure.Migrations
+{
+    /// <inheritdoc />
+    public partial class altrContracyAttachs : Migration
+    {
+        /// <inheritdoc />
+        protected override void Up(MigrationBuilder migrationBuilder)
+        {
+            migrationBuilder.DropForeignKey(
+                name: "FK_ContractTaskAttachment_AttachmentTypes_AttachmentTypeId",
+                table: "ContractTaskAttachment");
+
+            migrationBuilder.DropForeignKey(
+                name: "FK_ProjectStageAttachment_AttachmentTypes_AttachmentTypeId",
+                table: "ProjectStageAttachment");
+
+            migrationBuilder.DropIndex(
+                name: "IX_ProjectStageAttachment_AttachmentTypeId",
+                table: "ProjectStageAttachment");
+
+            migrationBuilder.DropIndex(
+                name: "IX_ContractTaskAttachment_AttachmentTypeId",
+                table: "ContractTaskAttachment");
+
+            migrationBuilder.DropColumn(
+                name: "Content",
+                table: "ProjectStageAttachment");
+
+            migrationBuilder.DropColumn(
+                name: "Content",
+                table: "ContractTaskAttachment");
+        }
+
+        /// <inheritdoc />
+        protected override void Down(MigrationBuilder migrationBuilder)
+        {
+            migrationBuilder.AddColumn<byte[]>(
+                name: "Content",
+                table: "ProjectStageAttachment",
+                type: "varbinary(max)",
+                nullable: false,
+                defaultValue: new byte[0]);
+
+            migrationBuilder.AddColumn<byte[]>(
+                name: "Content",
+                table: "ContractTaskAttachment",
+                type: "varbinary(max)",
+                nullable: false,
+                defaultValue: new byte[0]);
+
+            migrationBuilder.CreateIndex(
+                name: "IX_ProjectStageAttachment_AttachmentTypeId",
+                table: "ProjectStageAttachment",
+                column: "AttachmentTypeId");
+
+            migrationBuilder.CreateIndex(
+                name: "IX_ContractTaskAttachment_AttachmentTypeId",
+                table: "ContractTaskAttachment",
+                column: "AttachmentTypeId");
+
+            migrationBuilder.AddForeignKey(
+                name: "FK_ContractTaskAttachment_AttachmentTypes_AttachmentTypeId",
+                table: "ContractTaskAttachment",
+                column: "AttachmentTypeId",
+                principalTable: "AttachmentTypes",
+                principalColumn: "Id");
+
+            migrationBuilder.AddForeignKey(
+                name: "FK_ProjectStageAttachment_AttachmentTypes_AttachmentTypeId",
+                table: "ProjectStageAttachment",
+                column: "AttachmentTypeId",
+                principalTable: "AttachmentTypes",
+                principalColumn: "Id");
+        }
+    }
+}

+ 3 - 24
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)");
@@ -809,10 +812,6 @@ namespace MTWorkHR.Infrastructure.Migrations
                     b.Property<long?>("AttachmentTypeId")
                         .HasColumnType("bigint");
 
-                    b.Property<byte[]>("Content")
-                        .IsRequired()
-                        .HasColumnType("varbinary(max)");
-
                     b.Property<string>("ContentType")
                         .HasColumnType("nvarchar(max)");
 
@@ -850,8 +849,6 @@ namespace MTWorkHR.Infrastructure.Migrations
 
                     b.HasKey("Id");
 
-                    b.HasIndex("AttachmentTypeId");
-
                     b.HasIndex("ContractTaskId");
 
                     b.ToTable("ContractTaskAttachment");
@@ -3765,10 +3762,6 @@ namespace MTWorkHR.Infrastructure.Migrations
                     b.Property<long?>("AttachmentTypeId")
                         .HasColumnType("bigint");
 
-                    b.Property<byte[]>("Content")
-                        .IsRequired()
-                        .HasColumnType("varbinary(max)");
-
                     b.Property<string>("ContentType")
                         .HasColumnType("nvarchar(max)");
 
@@ -3806,8 +3799,6 @@ namespace MTWorkHR.Infrastructure.Migrations
 
                     b.HasKey("Id");
 
-                    b.HasIndex("AttachmentTypeId");
-
                     b.HasIndex("ProjectStageId");
 
                     b.ToTable("ProjectStageAttachment");
@@ -5355,18 +5346,12 @@ namespace MTWorkHR.Infrastructure.Migrations
 
             modelBuilder.Entity("MTWorkHR.Core.Entities.ContractTaskAttachment", b =>
                 {
-                    b.HasOne("MTWorkHR.Core.Entities.Base.AttachmentType", "AttachmentType")
-                        .WithMany()
-                        .HasForeignKey("AttachmentTypeId");
-
                     b.HasOne("MTWorkHR.Core.Entities.ContractTask", "ContractTask")
                         .WithMany("TaskAttachments")
                         .HasForeignKey("ContractTaskId")
                         .OnDelete(DeleteBehavior.Cascade)
                         .IsRequired();
 
-                    b.Navigation("AttachmentType");
-
                     b.Navigation("ContractTask");
                 });
 
@@ -5422,18 +5407,12 @@ namespace MTWorkHR.Infrastructure.Migrations
 
             modelBuilder.Entity("MTWorkHR.Core.Entities.ProjectStageAttachment", b =>
                 {
-                    b.HasOne("MTWorkHR.Core.Entities.Base.AttachmentType", "AttachmentType")
-                        .WithMany()
-                        .HasForeignKey("AttachmentTypeId");
-
                     b.HasOne("MTWorkHR.Core.Entities.ProjectStage", "ProjectStage")
                         .WithMany("StageAttachments")
                         .HasForeignKey("ProjectStageId")
                         .OnDelete(DeleteBehavior.Cascade)
                         .IsRequired();
 
-                    b.Navigation("AttachmentType");
-
                     b.Navigation("ProjectStage");
                 });
 

+ 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()