Browse Source

altrTaskHistory : fix assignedTo

zinab_elgendy 5 months ago
parent
commit
64220fa69f
27 changed files with 7333 additions and 34 deletions
  1. 1 1
      MTWorkHR.API/Controllers/AttendanceController.cs
  2. 1 1
      MTWorkHR.API/Controllers/MeetingController.cs
  3. 3 3
      MTWorkHR.API/Controllers/OrderRequestController.cs
  4. 10 4
      MTWorkHR.API/Controllers/UserTaskController.cs
  5. 1 1
      MTWorkHR.API/Program.cs
  6. 1 1
      MTWorkHR.Application/Dtos/Attendance/OrderRequestDto.cs
  7. 1 0
      MTWorkHR.Application/Dtos/Identity/AttachmentDto.cs
  8. 15 0
      MTWorkHR.Application/Dtos/User/OrderStatusDto.cs
  9. 15 0
      MTWorkHR.Application/Dtos/User/TaskStatusDto.cs
  10. 17 0
      MTWorkHR.Application/Dtos/User/TaskUserDto.cs
  11. 12 6
      MTWorkHR.Application/Dtos/User/UserTaskDto.cs
  12. 5 1
      MTWorkHR.Application/Dtos/User/UserTaskHistoryDto.cs
  13. 1 1
      MTWorkHR.Application/Mapper/MappingProfile.cs
  14. 1 0
      MTWorkHR.Application/Services/Interfaces/IUserTaskService.cs
  15. 25 1
      MTWorkHR.Application/Services/Task/UserTaskAttachmentService.cs
  16. 41 9
      MTWorkHR.Application/Services/Task/UserTaskService.cs
  17. 5 1
      MTWorkHR.Application/Services/User/OrderRequestService.cs
  18. 21 0
      MTWorkHR.Core/Entities/User/TaskUser.cs
  19. 1 0
      MTWorkHR.Core/Entities/User/UserTask.cs
  20. 4 0
      MTWorkHR.Core/Entities/User/UserTaskAttachment.cs
  21. 1 1
      MTWorkHR.Core/Entities/User/UserTaskHistory.cs
  22. 1 1
      MTWorkHR.Infrastructure/InfrastructureServiceRegistration.cs
  23. 3476 0
      MTWorkHR.Infrastructure/Migrations/20240730154025_addTaskUserTbl.Designer.cs
  24. 52 0
      MTWorkHR.Infrastructure/Migrations/20240730154025_addTaskUserTbl.cs
  25. 3486 0
      MTWorkHR.Infrastructure/Migrations/20240801152322_altrTaskHistory3.Designer.cs
  26. 67 0
      MTWorkHR.Infrastructure/Migrations/20240801152322_altrTaskHistory3.cs
  27. 69 2
      MTWorkHR.Infrastructure/Migrations/HRDataContextModelSnapshot.cs

+ 1 - 1
MTWorkHR.API/Controllers/AttendanceController.cs

@@ -54,7 +54,7 @@ namespace MTWorkHR.API.Controllers
         [HttpPost("Delete")]
         [ProducesResponseType(StatusCodes.Status200OK)]
 
-        public async Task Delete(long id)
+        public async Task Delete([FromQuery] long id)
         {
             await _AttendanceService.Delete(id);
         }

+ 1 - 1
MTWorkHR.API/Controllers/MeetingController.cs

@@ -54,7 +54,7 @@ namespace MTWorkHR.API.Controllers
         [HttpPost("Delete")]
         [ProducesResponseType(StatusCodes.Status200OK)]
 
-        public async Task Delete(long id)
+        public async Task Delete([FromQuery]long id)
         {
             await _MeetingService.Delete(id);
         }

+ 3 - 3
MTWorkHR.API/Controllers/OrderRequestController.cs

@@ -54,16 +54,16 @@ namespace MTWorkHR.API.Controllers
         [HttpPost("Delete")]
         [ProducesResponseType(StatusCodes.Status200OK)]
 
-        public async Task Delete(long id)
+        public async Task Delete([FromQuery]long id)
         {
             await _LeaveRequestService.Delete(id);
         }
         [HttpPost("ChangeStatus")]
         [ProducesResponseType(StatusCodes.Status200OK)]
 
-        public async Task ChangeStatus(long id, int statusId)
+        public async Task ChangeStatus([FromBody] OrderStatusDto input)
         {
-            await _LeaveRequestService.ChangeStatus(id, statusId);
+            await _LeaveRequestService.ChangeStatus(input.OrderId, input.StatusId);
         }
 
 

+ 10 - 4
MTWorkHR.API/Controllers/UserTaskController.cs

@@ -46,9 +46,9 @@ namespace MTWorkHR.API.Controllers
         [HttpPost("Update")]
         [ProducesResponseType(StatusCodes.Status200OK)]
 
-        public async Task Update([FromBody] UserTaskDto input)
+        public async Task<ActionResult<UserTaskDto>> Update([FromBody] UserTaskDto input)
         {
-            await _userTaskService.Update(input);
+            return await _userTaskService.Update(input);
         }
 
         [HttpPost("Delete")]
@@ -77,7 +77,7 @@ namespace MTWorkHR.API.Controllers
 
         [HttpPost("DeleteAttachment")]
         [ProducesResponseType(StatusCodes.Status200OK)]
-        public async Task DeleteAttachment(long id)
+        public async Task DeleteAttachment([FromQuery] long id)
         {
             await _attachmentService.Delete(id);
         }
@@ -100,11 +100,17 @@ namespace MTWorkHR.API.Controllers
         }
         [HttpPost("DeleteTaskHistory")]
         [ProducesResponseType(StatusCodes.Status200OK)]
-        public async Task DeleteTaskHistory(long id)
+        public async Task DeleteTaskHistory([FromQuery]long id)
         {
             await _taskHistoryService.Delete(id);
         }
+        [HttpPost("ChangeStatus")]
+        [ProducesResponseType(StatusCodes.Status200OK)]
 
+        public async Task ChangeStatus([FromBody] TaskStatusDto input)
+        {
+            await _userTaskService.ChangeStatus(input.TaskId, input.StatusId);
+        }
         #endregion
 
     }

+ 1 - 1
MTWorkHR.API/Program.cs

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

+ 1 - 1
MTWorkHR.Application/Dtos/Attendance/OrderRequestDto.cs

@@ -24,6 +24,6 @@ namespace MTWorkHR.Application.Models
         public int? CityId { get; set; }
         public OrderTypeDto? OrderType { get; set; }
         public LeaveTypeDto? LeaveType { get; set; }
-        public Employee? Employee { get; set; }
+        public UserDto? Employee { get; set; }
     }
 }

+ 1 - 0
MTWorkHR.Application/Dtos/Identity/AttachmentDto.cs

@@ -15,6 +15,7 @@ namespace MTWorkHR.Application.Models
         public IFormFile? FileData { get; set; }
         public string? FileName { get; set; }
 
+        public string? CreateDate { get; set; }
         public string? OriginalName { get; set; }
         public string? FilePath { get; set; }
         public byte[]? Content { get; set; }

+ 15 - 0
MTWorkHR.Application/Dtos/User/OrderStatusDto.cs

@@ -0,0 +1,15 @@
+using Microsoft.AspNetCore.Http;
+using MTWorkHR.Core.Entities;
+using MTWorkHR.Core.Entities.Base;
+using System.ComponentModel.DataAnnotations;
+using System.ComponentModel.DataAnnotations.Schema;
+
+namespace MTWorkHR.Application.Models
+{
+    public class OrderStatusDto
+    {
+        public long OrderId { get; set; }
+        public int StatusId { get; set; }
+
+    }
+}

+ 15 - 0
MTWorkHR.Application/Dtos/User/TaskStatusDto.cs

@@ -0,0 +1,15 @@
+using Microsoft.AspNetCore.Http;
+using MTWorkHR.Core.Entities;
+using MTWorkHR.Core.Entities.Base;
+using System.ComponentModel.DataAnnotations;
+using System.ComponentModel.DataAnnotations.Schema;
+
+namespace MTWorkHR.Application.Models
+{
+    public class TaskStatusDto
+    {
+        public long TaskId { get; set; }
+        public int StatusId { get; set; }
+
+    }
+}

+ 17 - 0
MTWorkHR.Application/Dtos/User/TaskUserDto.cs

@@ -0,0 +1,17 @@
+using Microsoft.AspNetCore.Http;
+using MTWorkHR.Core.Entities;
+using MTWorkHR.Core.Entities.Base;
+using System.ComponentModel.DataAnnotations;
+using System.ComponentModel.DataAnnotations.Schema;
+
+namespace MTWorkHR.Application.Models
+{
+    public class TaskUserDto : EntityDto
+    {
+        public long TaskId { get; set; }
+        public string AssignedUserId { get; set; }
+        public string? AssignedUserName { get; set; }
+        public string? ProfileImage { get; set; }
+
+    }
+}

+ 12 - 6
MTWorkHR.Application/Dtos/User/UserTaskDto.cs

@@ -1,4 +1,6 @@
-using MTWorkHR.Core.Global;
+using MTWorkHR.Core.Entities;
+using MTWorkHR.Core.Global;
+using System.ComponentModel.DataAnnotations;
 
 namespace MTWorkHR.Application.Models
 {
@@ -6,16 +8,20 @@ namespace MTWorkHR.Application.Models
     {
         public string AssignedUserId { get; set; }
         public string? AssignedUserName { get; set; }
-
+        public string? ProfileImage { get; set; }
+        [Required]
         public string Title { get; set; }
         public string Description { get; set; }
         public DateTime DueDate { get; set; }
-        public PriorityEnum Priority { get; set; }
+        public PriorityEnum? Priority { get; set; }
+        [Required]
         public int ProjectId { get; set; }
-
+        [Required]
         public long StatusId { get; set; }
-        public List<AttachmentDto> TaskAttachments { get; set; }
-        public List<UserTaskHistoryDto> TaskHistories { get; set; }
+   //     public List<string>? TaskUserIds { get; set; }
+        public List<AttachmentDto>? TaskAttachments { get; set; }
+        public List<UserTaskHistoryDto>? TaskHistories { get; set; }
+     //   public List<TaskUserDto>? TaskUsers { get; set; }
         public string? CreateUser { get; set; }
 
     }

+ 5 - 1
MTWorkHR.Application/Dtos/User/UserTaskHistoryDto.cs

@@ -9,7 +9,11 @@ namespace MTWorkHR.Application.Models
 {
     public class UserTaskHistoryDto : EntityDto
     {
-        public long AssignedToUserId { get; set; }
+        public string AssignedToUserId { get; set; }
+        public string? AssignedToUserName { get; set; }
+        public string? ProfileImage { get; set; }
+        public DateTime? CreateDate { get; set; }
+
         [MaxLength(500)]
         public string? Comment { get; set; }
 

+ 1 - 1
MTWorkHR.Application/Mapper/MappingProfile.cs

@@ -77,7 +77,7 @@ namespace MTWorkHR.Application.Mapper
 
             CreateMap<ProjectDto, Project>().ForMember(d => d.CreateDate, o => o.Ignore()).ForMember(d => d.CreateUser, o => o.Ignore());
             CreateMap<UserTaskDto, UserTask>().ForMember(d => d.CreateDate, o => o.Ignore()).ForMember(d => d.CreateUser, o => o.Ignore()).ReverseMap();
-            CreateMap<UserTaskAttachment, AttachmentDto>().ReverseMap();
+            CreateMap<UserTaskAttachment, AttachmentDto>().ForMember(d => d.CreateDate, o => o.Ignore()).ReverseMap();
             CreateMap<UserTaskHistoryDto, UserTaskHistory>().ForMember(d => d.CreateDate, o => o.Ignore()).ReverseMap();
 
             CreateMap<UserTask, UserTaskAllDto>()

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

@@ -9,6 +9,7 @@ namespace MTWorkHR.Application.Services.Interfaces
     public interface IUserTaskService : IService<UserTask, UserTaskDto, UserTaskDto>
     {
         Task<UserTaskDto> GetByUserId(string userId);
+        Task ChangeStatus(long taskId, int statusId);
         Task<PagingResultDto<UserTaskAllDto>> GetAll(UserTaskPagingInputDto PagingInputDto);
 
     }

+ 25 - 1
MTWorkHR.Application/Services/Task/UserTaskAttachmentService.cs

@@ -10,6 +10,8 @@ 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
 {
@@ -37,7 +39,15 @@ namespace MTWorkHR.Application.Services
         public override async Task<AttachmentDto> Create(AttachmentDto input)
         {
             if (input.FileData != null)
-                input.FileName = await _fileService.UploadFile(input.FileData);
+            {
+               // input.FilePath = await _fileService.UploadFile(input.FileData);
+                input.OriginalName = input.FileData.FileName;
+                List<AttachmentDto> attachs = new List<AttachmentDto>();
+                attachs.Add(input);
+                _fileService.CopyFileToCloud(ref attachs);
+
+            }
+            
             var entity = MapperObject.Mapper.Map<UserTaskAttachment>(input);
             if (entity is null)
             {
@@ -48,6 +58,20 @@ namespace MTWorkHR.Application.Services
             await _unitOfWork.CompleteAsync();
 
             var response = MapperObject.Mapper.Map<AttachmentDto>(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;
         }
 

+ 41 - 9
MTWorkHR.Application/Services/Task/UserTaskService.cs

@@ -9,14 +9,13 @@ using Microsoft.EntityFrameworkCore;
 using System.Linq.Dynamic.Core;
 using MTWorkHR.Core.IDto;
 using MTWorkHR.Application.Identity;
+using MTWorkHR.Core.Entities.Base;
 
 namespace MTWorkHR.Application.Services
 {
     public class UserTaskService : BaseService<UserTask, UserTaskDto, UserTaskDto>, IUserTaskService
     {
         private readonly IUnitOfWork _unitOfWork;
-        //private readonly AppSettingsConfiguration _configuration;
-        //private readonly GlobalInfo _globalInfo;
         private readonly IFileService _fileService;
         private readonly GlobalInfo _globalInfo;
         private readonly IUserService _userService;
@@ -34,12 +33,16 @@ namespace MTWorkHR.Application.Services
         {
             var entity = await _unitOfWork.UserTask.GetByIdWithAllChildren(id);
             var response = MapperObject.Mapper.Map<UserTaskDto>(entity);
+            await GetUserData(response);
             return response;
         }
         public async Task<UserTaskDto> GetByUserId(string userId)
         {
             var entity = await _unitOfWork.UserTask.GetByUserIdWithAllChildren(userId);
+           
             var response = MapperObject.Mapper.Map<UserTaskDto>(entity);
+            await GetUserData(response);
+
             return response;
         }
 
@@ -110,9 +113,12 @@ namespace MTWorkHR.Application.Services
 
         public override async Task<UserTaskDto> Create(UserTaskDto input)
         {
-            if(input.TaskAttachments?.Count > 0)
-                if ( !await _fileService.CopyFileToActualFolder(input.TaskAttachments.ToList()))
-                    throw new AppException(ExceptionEnum.CouldNotMoveFiles);
+            if (input.TaskAttachments?.Count > 0)
+            {
+                var attachs = input.TaskAttachments.ToList();
+                _fileService.CopyFileToCloud(ref attachs);
+            }
+
             var entity = MapperObject.Mapper.Map<UserTask>(input);
             if (entity is null)
             {
@@ -123,22 +129,48 @@ namespace MTWorkHR.Application.Services
             await _unitOfWork.CompleteAsync();
 
             var response = MapperObject.Mapper.Map<UserTaskDto>(task);
+            await GetUserData(response);
             return response;
         }
 
+        private async Task GetUserData(UserTaskDto response)
+        {
+            if (response.AssignedUserId != null)
+            {
+                var user = await _userService.GetUserWithAttachmentById(response.AssignedUserId);
+                if (user != null)
+                {
+                    response.AssignedUserName = user.FirstName + " " + user.LastName;
+                    var image = user.UserAttachments?.FirstOrDefault(a => a.AttachmentTypeId == 9);
+                    response.ProfileImage = image != null ? image.FilePath : "";
+                }
+            }
+        }
 
         public override async Task<UserTaskDto> Update(UserTaskDto input)
         {
-            var entitiy = await _unitOfWork.UserTask.GetByIdAsync(input.Id);
+            var entity = await _unitOfWork.UserTask.GetByIdAsync(input.Id);
 
-            if (entitiy == null)
+            if (entity == null)
                 throw new AppException(ExceptionEnum.RecordNotExist);
 
-            MapperObject.Mapper.Map(input, entitiy, typeof(UserTaskDto), typeof(UserTask));
+            MapperObject.Mapper.Map(input, entity, typeof(UserTaskDto), typeof(UserTask));
 
             await _unitOfWork.CompleteAsync();
+            var response = Mapper.MapperObject.Mapper.Map<UserTaskDto>(entity);
+            await GetUserData(response);
+
+            return response;
+        }
 
-            return input;
+        public async Task ChangeStatus(long taskId, int statusId)
+        {
+            var entity = await _unitOfWork.UserTask.GetByIdAsync(taskId);
+            if (entity == null)
+                throw new AppException(ExceptionEnum.RecordNotExist);
+            entity.StatusId = statusId;
+           
+            await _unitOfWork.CompleteAsync();
         }
     }
 }

+ 5 - 1
MTWorkHR.Application/Services/User/OrderRequestService.cs

@@ -24,13 +24,15 @@ namespace MTWorkHR.Application.Services
         private readonly IMailSender _emailSender;
         private readonly ApplicationUserManager _userManager;
         private readonly GlobalInfo _globalInfo;
+        private readonly IUserService _userService;
 
-        public OrderRequestService(IUnitOfWork unitOfWork, IMailSender emailSender, ApplicationUserManager userManager, GlobalInfo globalInfo) : base(unitOfWork)
+        public OrderRequestService(IUnitOfWork unitOfWork, IMailSender emailSender, ApplicationUserManager userManager, GlobalInfo globalInfo, IUserService userService) : base(unitOfWork)
         {
             _unitOfWork = unitOfWork;
             _emailSender = emailSender;
             _userManager = userManager;
             _globalInfo = globalInfo;
+            _userService = userService;
         }
 
 
@@ -38,8 +40,10 @@ namespace MTWorkHR.Application.Services
         {
             var entity = await _unitOfWork.OrderRequest.GetByIdWithAllChildren(id);
             var response = MapperObject.Mapper.Map<OrderRequestDto>(entity);
+            response.Employee = await _userService.GetUserWithAttachmentById(entity.RequestingEmployeeId);
             return response;
         }
+      
         public override async Task<PagingResultDto<OrderRequestDto>> GetAll(PagingInputDto PagingInputDto)
         {
             var res = await _unitOfWork.OrderRequest.GetAllWithChildrenAsync();

+ 21 - 0
MTWorkHR.Core/Entities/User/TaskUser.cs

@@ -0,0 +1,21 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
+using System.ComponentModel.DataAnnotations.Schema;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using MTWorkHR.Core.Entities.Base;
+
+namespace MTWorkHR.Core.Entities
+{
+    public class TaskUser : AuditEntity
+    {
+        public long TaskId{ get; set; }
+        [ForeignKey("TaskId")]
+        public UserTask? UserTask { get; set; }
+        public string AssignedUserId { get; set; }
+        public string? AssignedUserName { get; set; }
+
+    }
+}

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

@@ -28,6 +28,7 @@ namespace MTWorkHR.Core.Entities
         public UserTaskStatus TaskStatus { get; set; }
         public List<UserTaskAttachment> TaskAttachments { get; set; }
         public List<UserTaskHistory> TaskHistories { get; set; }
+        public List<TaskUser>? TaskUsers { get; set; }
         public long CompanyId { get ; set ; }
     }
 }

+ 4 - 0
MTWorkHR.Core/Entities/User/UserTaskAttachment.cs

@@ -21,5 +21,9 @@ 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 - 1
MTWorkHR.Core/Entities/User/UserTaskHistory.cs

@@ -12,7 +12,7 @@ namespace MTWorkHR.Core.Entities
 {
     public class UserTaskHistory : AuditEntity
     {
-        public long AssignedToUserId { get; set; }
+        public string? AssignedToUserId { get; set; }
         [MaxLength(500)]
         [Filter]
         public string? Comment { get; set; }

+ 1 - 1
MTWorkHR.Infrastructure/InfrastructureServiceRegistration.cs

@@ -31,7 +31,7 @@ namespace MTWorkHR.Infrastructure
             
             services.AddDbContext<HRDataContext>(options =>
                 options.UseSqlServer(
-                    config.ConnectionStrings.LocalConnectionString  //configuration.GetSection("ConnectionString:MTWorkHRConnectionString").Value
+                    config.ConnectionStrings.MTWorkHRConnectionString  //configuration.GetSection("ConnectionString:MTWorkHRConnectionString").Value
                     ));
            
             services.AddIdentity<ApplicationUser, ApplicationRole>().AddEntityFrameworkStores<HRDataContext>().AddDefaultTokenProviders();

File diff suppressed because it is too large
+ 3476 - 0
MTWorkHR.Infrastructure/Migrations/20240730154025_addTaskUserTbl.Designer.cs


+ 52 - 0
MTWorkHR.Infrastructure/Migrations/20240730154025_addTaskUserTbl.cs

@@ -0,0 +1,52 @@
+using System;
+using Microsoft.EntityFrameworkCore.Migrations;
+
+#nullable disable
+
+namespace MTWorkHR.Infrastructure.Migrations
+{
+    /// <inheritdoc />
+    public partial class addTaskUserTbl : Migration
+    {
+        /// <inheritdoc />
+        protected override void Up(MigrationBuilder migrationBuilder)
+        {
+            migrationBuilder.CreateTable(
+                name: "TaskUser",
+                columns: table => new
+                {
+                    Id = table.Column<long>(type: "bigint", nullable: false)
+                        .Annotation("SqlServer:Identity", "1, 1"),
+                    CreateUser = table.Column<string>(type: "nvarchar(450)", maxLength: 450, nullable: true),
+                    UpdateUser = table.Column<string>(type: "nvarchar(450)", maxLength: 450, nullable: true),
+                    CreateDate = table.Column<DateTime>(type: "datetime2", nullable: false),
+                    UpdateDate = table.Column<DateTime>(type: "datetime2", nullable: true),
+                    TaskId = table.Column<long>(type: "bigint", nullable: false),
+                    AssignedUserId = table.Column<string>(type: "nvarchar(max)", nullable: false),
+                    AssignedUserName = table.Column<string>(type: "nvarchar(max)", nullable: true)
+                },
+                constraints: table =>
+                {
+                    table.PrimaryKey("PK_TaskUser", x => x.Id);
+                    table.ForeignKey(
+                        name: "FK_TaskUser_UserTasks_TaskId",
+                        column: x => x.TaskId,
+                        principalTable: "UserTasks",
+                        principalColumn: "Id",
+                        onDelete: ReferentialAction.Cascade);
+                });
+
+            migrationBuilder.CreateIndex(
+                name: "IX_TaskUser_TaskId",
+                table: "TaskUser",
+                column: "TaskId");
+        }
+
+        /// <inheritdoc />
+        protected override void Down(MigrationBuilder migrationBuilder)
+        {
+            migrationBuilder.DropTable(
+                name: "TaskUser");
+        }
+    }
+}

File diff suppressed because it is too large
+ 3486 - 0
MTWorkHR.Infrastructure/Migrations/20240801152322_altrTaskHistory3.Designer.cs


+ 67 - 0
MTWorkHR.Infrastructure/Migrations/20240801152322_altrTaskHistory3.cs

@@ -0,0 +1,67 @@
+using Microsoft.EntityFrameworkCore.Migrations;
+
+#nullable disable
+
+namespace MTWorkHR.Infrastructure.Migrations
+{
+    /// <inheritdoc />
+    public partial class altrTaskHistory3 : Migration
+    {
+        /// <inheritdoc />
+        protected override void Up(MigrationBuilder migrationBuilder)
+        {
+            migrationBuilder.AlterColumn<string>(
+                name: "AssignedToUserId",
+                table: "UserTaskHistories",
+                type: "nvarchar(max)",
+                nullable: true,
+                oldClrType: typeof(long),
+                oldType: "bigint");
+
+            migrationBuilder.AddColumn<byte[]>(
+                name: "Content",
+                table: "UserTaskAttachments",
+                type: "varbinary(max)",
+                nullable: false,
+                defaultValue: new byte[0]);
+
+            migrationBuilder.AddColumn<string>(
+                name: "ContentType",
+                table: "UserTaskAttachments",
+                type: "nvarchar(max)",
+                nullable: true);
+
+            migrationBuilder.AddColumn<string>(
+                name: "FilePath",
+                table: "UserTaskAttachments",
+                type: "nvarchar(max)",
+                nullable: true);
+        }
+
+        /// <inheritdoc />
+        protected override void Down(MigrationBuilder migrationBuilder)
+        {
+            migrationBuilder.DropColumn(
+                name: "Content",
+                table: "UserTaskAttachments");
+
+            migrationBuilder.DropColumn(
+                name: "ContentType",
+                table: "UserTaskAttachments");
+
+            migrationBuilder.DropColumn(
+                name: "FilePath",
+                table: "UserTaskAttachments");
+
+            migrationBuilder.AlterColumn<long>(
+                name: "AssignedToUserId",
+                table: "UserTaskHistories",
+                type: "bigint",
+                nullable: false,
+                defaultValue: 0L,
+                oldClrType: typeof(string),
+                oldType: "nvarchar(max)",
+                oldNullable: true);
+        }
+    }
+}

+ 69 - 2
MTWorkHR.Infrastructure/Migrations/HRDataContextModelSnapshot.cs

@@ -1904,6 +1904,50 @@ namespace MTWorkHR.Infrastructure.Migrations
                     b.ToTable("SettingLogs");
                 });
 
+            modelBuilder.Entity("MTWorkHR.Core.Entities.TaskUser", b =>
+                {
+                    b.Property<long>("Id")
+                        .ValueGeneratedOnAdd()
+                        .HasColumnType("bigint")
+                        .HasColumnOrder(0);
+
+                    SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<long>("Id"));
+
+                    b.Property<string>("AssignedUserId")
+                        .IsRequired()
+                        .HasColumnType("nvarchar(max)");
+
+                    b.Property<string>("AssignedUserName")
+                        .HasColumnType("nvarchar(max)");
+
+                    b.Property<DateTime>("CreateDate")
+                        .HasColumnType("datetime2")
+                        .HasColumnOrder(3);
+
+                    b.Property<string>("CreateUser")
+                        .HasMaxLength(450)
+                        .HasColumnType("nvarchar(450)")
+                        .HasColumnOrder(1);
+
+                    b.Property<long>("TaskId")
+                        .HasColumnType("bigint");
+
+                    b.Property<DateTime?>("UpdateDate")
+                        .HasColumnType("datetime2")
+                        .HasColumnOrder(4);
+
+                    b.Property<string>("UpdateUser")
+                        .HasMaxLength(450)
+                        .HasColumnType("nvarchar(450)")
+                        .HasColumnOrder(2);
+
+                    b.HasKey("Id");
+
+                    b.HasIndex("TaskId");
+
+                    b.ToTable("TaskUser");
+                });
+
             modelBuilder.Entity("MTWorkHR.Core.Entities.Team", b =>
                 {
                     b.Property<long>("Id")
@@ -2332,6 +2376,13 @@ 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)");
+
                     b.Property<DateTime>("CreateDate")
                         .HasColumnType("datetime2")
                         .HasColumnOrder(3);
@@ -2345,6 +2396,9 @@ namespace MTWorkHR.Infrastructure.Migrations
                         .HasMaxLength(250)
                         .HasColumnType("nvarchar(250)");
 
+                    b.Property<string>("FilePath")
+                        .HasColumnType("nvarchar(max)");
+
                     b.Property<string>("OriginalName")
                         .HasMaxLength(250)
                         .HasColumnType("nvarchar(250)");
@@ -2379,8 +2433,8 @@ namespace MTWorkHR.Infrastructure.Migrations
 
                     SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<long>("Id"));
 
-                    b.Property<long>("AssignedToUserId")
-                        .HasColumnType("bigint");
+                    b.Property<string>("AssignedToUserId")
+                        .HasColumnType("nvarchar(max)");
 
                     b.Property<string>("Comment")
                         .HasMaxLength(500)
@@ -3142,6 +3196,17 @@ namespace MTWorkHR.Infrastructure.Migrations
                     b.Navigation("Project");
                 });
 
+            modelBuilder.Entity("MTWorkHR.Core.Entities.TaskUser", b =>
+                {
+                    b.HasOne("MTWorkHR.Core.Entities.UserTask", "UserTask")
+                        .WithMany("TaskUsers")
+                        .HasForeignKey("TaskId")
+                        .OnDelete(DeleteBehavior.Cascade)
+                        .IsRequired();
+
+                    b.Navigation("UserTask");
+                });
+
             modelBuilder.Entity("MTWorkHR.Core.Entities.TeamUser", b =>
                 {
                     b.HasOne("MTWorkHR.Core.Entities.Team", "Team")
@@ -3396,6 +3461,8 @@ namespace MTWorkHR.Infrastructure.Migrations
                     b.Navigation("TaskAttachments");
 
                     b.Navigation("TaskHistories");
+
+                    b.Navigation("TaskUsers");
                 });
 
             modelBuilder.Entity("MTWorkHR.Infrastructure.Entities.ApplicationRole", b =>