소스 검색

update user without multipart formFiles

zinab_elgendy 2 달 전
부모
커밋
e76f399536

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

@@ -42,10 +42,10 @@ namespace MTWorkHR.API.Controllers
 
         [HttpPost("Create")]
         [ProducesResponseType(StatusCodes.Status200OK)]
-       // [Consumes("multipart/form-data")]
+        [Consumes("multipart/form-data")]
         [AllowAnonymous]
         [AppAuthorize(Permissions = "Company.Create")]
-        public async Task<ActionResult<CompanyDto>> Create([FromBody] CompanyDto input)
+        public async Task<ActionResult<CompanyDto>> Create([FromForm] CompanyDto input)
         {
             return await _companyService.Create(input);
         }
@@ -54,7 +54,7 @@ namespace MTWorkHR.API.Controllers
         [ProducesResponseType(StatusCodes.Status200OK)]
        // [Consumes("multipart/form-data")]
         [AppAuthorize(Permissions = "Company.Update")]
-        public async Task<ActionResult<CompanyDto>> Update([FromBody] CompanyDto input)
+        public async Task<ActionResult<UpdateCompanyDto>> Update([FromBody] UpdateCompanyDto input)
         {
             return await _companyService.Update(input);
         }

+ 2 - 2
MTWorkHR.API/Controllers/UserController.cs

@@ -62,9 +62,9 @@ namespace MTWorkHR.API.Controllers
 
         [HttpPost("Create")]
         [ProducesResponseType(StatusCodes.Status200OK)]
-       // [Consumes("multipart/form-data")]
+        [Consumes("multipart/form-data")]
         [AppAuthorize(Permissions = "User.Create")]
-        public async Task<ActionResult<UserDto>> Create([FromBody] UserDto input)
+        public async Task<ActionResult<UserDto>> Create([FromForm] UserDto input)
         {
             return await _userService.Create(input);
         }

+ 10 - 10
MTWorkHR.Application/Dtos/Identity/UserDto.cs

@@ -56,19 +56,19 @@ namespace MTWorkHR.Application.Models
         public bool IsCheckedIn { get; set; }
         public bool IsCheckedOut { get; set; }
         public string? ProfileImagePath { get; set; }
-        public AttachmentDto? ProfileImage { get; set; }
-        public AttachmentDto? CVAttach { get; set; }
-        public AttachmentDto? PassportAttach { get; set; }
-        public AttachmentDto? EduCertificateAttach { get; set; }
-        public AttachmentDto? ExperienceCertificateAttach { get; set; }
-        public AttachmentDto? ProfCertificateAttach { get; set; }
+        public FormFile? ProfileImage { get; set; }
+        public FormFile? CVAttach { get; set; }
+        public FormFile? PassportAttach { get; set; }
+        public FormFile? EduCertificateAttach { get; set; }
+        public FormFile? ExperienceCertificateAttach { get; set; }
+        public FormFile? ProfCertificateAttach { get; set; }
         //Company attach
-        public AttachmentDto? CommercialRegAttach { get; set; }
-        public AttachmentDto? TaxDeclarationAttach { get; set; }
-        public AttachmentDto? IdAttach { get; set; }
+        public FormFile? CommercialRegAttach { get; set; }
+        public FormFile? TaxDeclarationAttach { get; set; }
+        public FormFile? IdAttach { get; set; }
 
         public IList<UserRoleDto>? UserRoles { get; set; }
-        public IList<AttachmentDto>? UserAttachments{ get; set; }
+        public IList<AttachmentDto>? UserAttachments { get; set; }
         public UserAddressDto? UserAddress{ get; set; }
     }
 }

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

@@ -47,6 +47,7 @@ namespace MTWorkHR.Application.Models
         public decimal IncomeTaxValue { get; set; }
         public string? Position { get; set; }
         public long? CompanyId { get; set; }
+        public string? ProfileImagePath { get; set; }
         public AttachmentDto? ProfileImage { get; set; }
 
         public AttachmentDto? CVAttach { get; set; }

+ 6 - 6
MTWorkHR.Application/Dtos/User/CompanyDto.cs

@@ -25,12 +25,12 @@ namespace MTWorkHR.Application.Models
         public string? CountryName { get; set; }
         public UserTypeEnum? UserType { get; set; }
         public CompanyUserDto? CompanyUser { get; set; }
-        public AttachmentDto? ProfileImage { get; set; }
-        public AttachmentDto? CommercialRegAttach { get; set; }
-        public AttachmentDto? TaxDeclarationAttach { get; set; }
-        public AttachmentDto? PassportAttach { get; set; }
-        public AttachmentDto? ExperienceCertificateAttach { get; set; }
-        public AttachmentDto? IdAttach { get; set; }
+        public FormFile? ProfileImage { get; set; }
+        public FormFile? CommercialRegAttach { get; set; }
+        public FormFile? TaxDeclarationAttach { get; set; }
+        public FormFile? PassportAttach { get; set; }
+        public FormFile? ExperienceCertificateAttach { get; set; }
+        public FormFile? IdAttach { get; set; }
         public string? CreateUser { get; set; }
         public bool IsSuspended { get; set; }
 

+ 39 - 0
MTWorkHR.Application/Dtos/User/UpdateCompanyDto.cs

@@ -0,0 +1,39 @@
+using Microsoft.AspNetCore.Http;
+using MTWorkHR.Core.Global;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace MTWorkHR.Application.Models
+{
+    public class UpdateCompanyDto : EntityDto
+    {
+        public string CompanyName { get; set; }
+
+        public string CRNumber { get; set; } //Commercial Registration
+        public string? UserId { get; set; }
+        public string? PhoneNumber { get; set; }
+        public string? Address { get; set; }
+        public string? Email { get; set; }
+        public long? CountryId { get; set; }
+        public long? CityId { get; set; }
+        public string? CityName { get; set; }
+        public string? PostalCode { get; set; }
+        public string? CountryName { get; set; }
+        public UserTypeEnum? UserType { get; set; }
+        public CompanyUserDto? CompanyUser { get; set; }
+        public AttachmentDto? ProfileImage { get; set; }
+        public AttachmentDto? CommercialRegAttach { get; set; }
+        public AttachmentDto? TaxDeclarationAttach { get; set; }
+        public AttachmentDto? PassportAttach { get; set; }
+        public AttachmentDto? ExperienceCertificateAttach { get; set; }
+        public AttachmentDto? IdAttach { get; set; }
+        public string? CreateUser { get; set; }
+        public bool IsSuspended { get; set; }
+
+
+    }
+}

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

@@ -1,6 +1,7 @@
 using AutoMapper;
 using Azure;
 using Countries.NET;
+using Microsoft.AspNetCore.Http;
 using Microsoft.AspNetCore.Identity;
 using MTWorkHR.Application.Models;
 using MTWorkHR.Core.Entities;
@@ -50,9 +51,24 @@ namespace MTWorkHR.Application.Mapper
                 .ForMember(m => m.Id, op => op.Ignore());
 
             CreateMap<ApplicationUser, UserUpdateDto>().ForMember(m => m.Password, op => op.Ignore());
-            CreateMap<UserDto, UserUpdateDto>().ReverseMap();
+            CreateMap<UserDto, UserUpdateDto>()
+                //.ForMember(m => m.CVAttach, op => op.Ignore())
+                //.ForMember(m => m.EduCertificateAttach, op => op.Ignore())
+                //.ForMember(m => m.ExperienceCertificateAttach, op => op.Ignore())
+                //.ForMember(m => m.PassportAttach, op => op.Ignore())
+                //.ForMember(m => m.ProfCertificateAttach, op => op.Ignore())
+                //.ForMember(m => m.ProfileImage, op => op.Ignore())
+                .ReverseMap();
             CreateMap<UserBasicInfoDto, ApplicationUser>().ReverseMap();
             CreateMap<UserBasicInfoDto, UserDto>().ReverseMap();
+
+
+
+            CreateMap<IFormFile, AttachmentDto>()
+            .ForMember(dest => dest.FileData, opt => opt.MapFrom(src => src))
+            .ForMember(dest => dest.FileName, opt => opt.MapFrom(src => src.FileName))
+            .ForMember(dest => dest.OriginalName, opt => opt.MapFrom(src => src.FileName)) // Adjust if OriginalName differs
+            .ForMember(dest => dest.FilePath, opt => opt.Ignore()); // Ignore FilePath or map if you have logic
             // -------------------view Employee info
             CreateMap<ApplicationUser, EmployeeInfoDto>()
               .ForMember(s => s.QualificationName, o => o.MapFrom(s => s.Qualification == null ? "" : GlobalInfo.lang == "ar" ? s.Qualification.NameAr : s.Qualification.NameEn))
@@ -144,6 +160,8 @@ namespace MTWorkHR.Application.Mapper
 
             CreateMap<OrderType, OrderTypeDto>().ReverseMap();
             CreateMap<LeaveType, LeaveTypeDto>().ReverseMap();
+            CreateMap<Company, UpdateCompanyDto>();
+            CreateMap<UpdateCompanyDto, Company>().ForMember(d => d.CreateDate, o => o.Ignore()).ForMember(d => d.CreateUser, o => o.Ignore());
             CreateMap<CompanyDto, Company>().ForMember(d => d.CreateDate, o => o.Ignore()).ForMember(d => d.CreateUser, o => o.Ignore());
             CreateMap<Company, CompanyDto>()
                 .ForMember(s => s.CityName, o => o.MapFrom(s => s.City == null ? "" : GlobalInfo.lang == "ar" ? s.City.NameAr : s.City.NameEn))

+ 3 - 0
MTWorkHR.Application/Services/Base/BlobFileService.cs

@@ -67,6 +67,7 @@ namespace MTWorkHR.Application.Services
                 // Generate a unique file name to avoid overwriting
                 string uniqueFileName = GenerateUniqueFileName(file.FileName);
                 var blobClient = _containerClient.GetBlobClient(uniqueFileName);
+                _logger.LogInformation("0########## File upload start uniqueFileName={0}", uniqueFileName);
 
                 if (blobClient != null)
                 {
@@ -91,6 +92,8 @@ namespace MTWorkHR.Application.Services
                             file.FileName = uniqueFileName;
                         }
                     }
+                    _logger.LogInformation("1########## File upload finish path={0}", blobClient.Uri.AbsoluteUri);
+
                     return blobClient.Uri.AbsoluteUri;
                 }
                 else

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

@@ -16,6 +16,7 @@ namespace MTWorkHR.Application.Services.Interfaces
         Task<CompanyDto> GetById();
         Task<CompanyDto> GetById(long companyId);
         Task Suspend(long companyId);
+        Task<UpdateCompanyDto> Update(UpdateCompanyDto input);
 
     }
 }

+ 28 - 10
MTWorkHR.Application/Services/User/CompanyService.cs

@@ -136,13 +136,31 @@ namespace MTWorkHR.Application.Services
             //};
             var  UserAttachments = new List<AttachmentDto>();
 
-            AddAttachment(input.ProfileImage, 9, UserAttachments);
-            AddAttachment(input.CommercialRegAttach, 6, UserAttachments);
-            AddAttachment(input.PassportAttach, 2, UserAttachments);
-            AddAttachment(input.TaxDeclarationAttach, 7, UserAttachments);
-            AddAttachment(input.ExperienceCertificateAttach, 4, UserAttachments);
-            AddAttachment(input.IdAttach, 8, UserAttachments);
-          
+            if (input.ProfileImage != null)
+            {
+                UserAttachments.Add(new AttachmentDto { FileData = input.ProfileImage, OriginalName = input.ProfileImage?.Name, FileName = input.ProfileImage?.FileName, AttachmentTypeId = 9 });
+            }
+            if (input.CommercialRegAttach != null)
+            {
+                UserAttachments.Add(new AttachmentDto { FileData = input.CommercialRegAttach, OriginalName = input.CommercialRegAttach?.Name, FileName = input.CommercialRegAttach?.FileName, AttachmentTypeId = 6 });
+            }
+            if (input.PassportAttach != null)
+            {
+                UserAttachments.Add(new AttachmentDto { FileData = input.PassportAttach, OriginalName = input.PassportAttach?.Name, FileName = input.PassportAttach?.FileName, AttachmentTypeId = 2 });
+            }
+            if (input.TaxDeclarationAttach != null)
+            {
+                UserAttachments.Add(new AttachmentDto { FileData = input.TaxDeclarationAttach, OriginalName = input.TaxDeclarationAttach?.Name, FileName = input.TaxDeclarationAttach?.FileName, AttachmentTypeId = 7 });
+            }
+            if (input.ExperienceCertificateAttach != null)
+            {
+                UserAttachments.Add(new AttachmentDto { FileData = input.ExperienceCertificateAttach, OriginalName = input.ExperienceCertificateAttach?.Name, FileName = input.ExperienceCertificateAttach?.FileName, AttachmentTypeId = 4 });
+            }
+            if (input.IdAttach != null)
+            {
+                UserAttachments.Add(new AttachmentDto { FileData = input.IdAttach, OriginalName = input.IdAttach?.Name, FileName = input.IdAttach?.FileName, AttachmentTypeId = 8 });
+            }
+
             _fileService.CopyFileToCloud(ref UserAttachments);
             companyUser.UserAttachments = UserAttachments;
 
@@ -184,7 +202,7 @@ namespace MTWorkHR.Application.Services
             }
         }
 
-        public override async Task<CompanyDto> Update(CompanyDto input)
+        public async Task<UpdateCompanyDto> Update(UpdateCompanyDto input)
         {
             //var companyUser = MapperObject.Mapper.Map<UserUpdateDto>(input.CompanyUser);
             _unitOfWork.BeginTran();
@@ -196,14 +214,14 @@ namespace MTWorkHR.Application.Services
             if (entity == null)
                 throw new AppException(ExceptionEnum.RecordNotExist);
 
-            MapperObject.Mapper.Map(input, entity, typeof(CompanyDto), typeof(Company));
+            MapperObject.Mapper.Map(input, entity, typeof(UpdateCompanyDto), typeof(Company));
 
             await _unitOfWork.CompleteAsync();
             _unitOfWork.CommitTran();
 
             return input;
         }
-        public async Task<UserUpdateDto> UpdateCompanyUser(CompanyDto input)
+        public async Task<UserUpdateDto> UpdateCompanyUser(UpdateCompanyDto input)
         {
             try
             {

+ 117 - 39
MTWorkHR.Application/Services/User/UserService.cs

@@ -89,6 +89,81 @@ namespace MTWorkHR.Application.Services
             if (response.UserAttachments != null)
                 foreach (var attach in response.UserAttachments.Where(a => a.Content != null))
                 {
+                    //var stream = new MemoryStream(attach.Content);
+                    //IFormFile file = new FormFile(stream, 0, stream.Length, Path.GetFileNameWithoutExtension(attach.FileName), attach.FileName);
+
+                    using (var stream = new MemoryStream(attach.Content))
+                    {
+                        var file = new FormFile(stream, 0, stream.Length, Path.GetFileNameWithoutExtension(attach.FileName), attach.FilePath)
+                        {
+                            Headers = new HeaderDictionary(),
+                            ContentType = attach.ContentType,
+
+                        };
+
+                        System.Net.Mime.ContentDisposition cd = new System.Net.Mime.ContentDisposition
+                        {
+                            FileName = file.FileName
+                        };
+                        file.ContentDisposition = cd.ToString();
+                        switch (attach.AttachmentTypeId)
+                        {
+                            case 1:
+                                response.CVAttach = file;
+                                break;
+                            case 2:
+                                response.PassportAttach = file;
+                                break;
+                            case 3:
+                                response.EduCertificateAttach = file;
+                                break;
+                            case 4:
+                                response.ExperienceCertificateAttach = file;
+                                break;
+                            case 5:
+                                response.ProfCertificateAttach = file;
+                                break;
+                            case 6:
+                                response.CommercialRegAttach = file;
+                                break;
+                            case 7:
+                                response.TaxDeclarationAttach = file;
+                                break;
+                            case 8:
+                                response.IdAttach = file;
+                                break;
+                            case 9:
+                                response.ProfileImage = file;
+                                response.ProfileImagePath = attach.FilePath;
+                                break;
+                        }
+                        attach.Content = new byte[0];
+                    }
+
+                }
+
+            var attendance = await _unitOfWork.Attendance.GetAttendanceByUserId(id, DateTime.UtcNow.Date);
+            response.IsCheckedIn = attendance != null && attendance.CheckInTime.HasValue;
+            response.IsCheckedOut = attendance != null && attendance.CheckOutTime.HasValue;
+            return response;
+        }
+        public async Task<UserUpdateDto> GetByIdForUpdate(string id)
+        {
+            var entity = await _userManager.Users
+                .Include(x => x.UserRoles)
+                .Include(x => x.UserAddress).ThenInclude(x => x.City)
+                .Include(x => x.UserAddress).ThenInclude(x => x.Country)
+                .Include(x => x.UserAttachments)
+                .Include(x => x.JobTitle)
+                .Include(x => x.Industry)
+                .Include(x => x.University)
+                .Include(x => x.Country)
+                .Include(x => x.Qualification)
+                .FirstOrDefaultAsync(x => x.Id == id);
+            var response = MapperObject.Mapper.Map<UserUpdateDto>(entity);
+            if (response.UserAttachments != null)
+                foreach (var attach in response.UserAttachments)
+                {
                     switch (attach.AttachmentTypeId)
                     {
                         case 1:
@@ -101,20 +176,20 @@ namespace MTWorkHR.Application.Services
                             response.EduCertificateAttach = attach;
                             break;
                         case 4:
-                            response.ExperienceCertificateAttach= attach;
+                            response.ExperienceCertificateAttach = attach;
                             break;
                         case 5:
                             response.ProfCertificateAttach = attach;
                             break;
-                        case 6:
-                            response.CommercialRegAttach = attach;
-                            break;
-                        case 7:
-                            response.TaxDeclarationAttach = attach;
-                            break;
-                        case 8:
-                            response.IdAttach = attach;
-                            break;
+                        //case 6:
+                        //    response.CommercialRegAttach = file;
+                        //    break;
+                        //case 7:
+                        //    response.TaxDeclarationAttach = file;
+                        //    break;
+                        //case 8:
+                        //    response.IdAttach = file;
+                        //    break;
                         case 9:
                             response.ProfileImage = attach;
                             response.ProfileImagePath = attach.FilePath;
@@ -122,10 +197,7 @@ namespace MTWorkHR.Application.Services
                     }
                     attach.Content = new byte[0];
                 }
-            
-            var attendance = await _unitOfWork.Attendance.GetAttendanceByUserId(id, DateTime.UtcNow.Date);
-            response.IsCheckedIn = attendance != null && attendance.CheckInTime.HasValue;
-            response.IsCheckedOut = attendance != null && attendance.CheckOutTime.HasValue;
+
             return response;
         }
 
@@ -446,18 +518,36 @@ namespace MTWorkHR.Application.Services
             //loop for given list of attachment, and move each file from Temp path to Actual path
             //  _fileService.UploadFiles(files);
             input.CountryId = input.CountryId == null || input.CountryId == 0 ? input.UserAddress?.CountryId : input.CountryId;
-           // if (input.UserAttachments == null )
-            input.UserAttachments = new List<AttachmentDto>();
-            AddAttachment(input.ProfileImage, 9,  input.UserAttachments);
-            AddAttachment(input.CVAttach, 1,  input.UserAttachments);
-            AddAttachment(input.PassportAttach, 2,  input.UserAttachments);
-            AddAttachment(input.EduCertificateAttach, 3,  input.UserAttachments);
-            AddAttachment(input.ExperienceCertificateAttach, 4,  input.UserAttachments);
-            AddAttachment(input.ProfCertificateAttach, 5,  input.UserAttachments);
-
+            if (input.UserAttachments == null)
+                input.UserAttachments = new List<AttachmentDto>();
+            if (input.ProfileImage != null)
+            {
+                input.UserAttachments.Add(new AttachmentDto { FileData = input.ProfileImage, OriginalName = input.ProfileImage?.Name, FileName = input.ProfileImage?.FileName, AttachmentTypeId = 9 });
+            }
+            if (input.CVAttach != null)
+            {
+                input.UserAttachments.Add(new AttachmentDto { FileData = input.CVAttach, OriginalName = input.CVAttach?.Name, FileName = input.CVAttach?.FileName, AttachmentTypeId = 1 });
+            }
+            if (input.PassportAttach != null)
+            {
+                input.UserAttachments.Add(new AttachmentDto { FileData = input.PassportAttach, OriginalName = input.PassportAttach?.Name, FileName = input.PassportAttach?.FileName, AttachmentTypeId = 2 });
+            }
+            if (input.EduCertificateAttach != null)
+            {
+                input.UserAttachments.Add(new AttachmentDto { FileData = input.EduCertificateAttach, OriginalName = input.EduCertificateAttach?.Name, FileName = input.EduCertificateAttach?.FileName, AttachmentTypeId = 3 });
+            }
+            if (input.ExperienceCertificateAttach != null)
+            {
+                input.UserAttachments.Add(new AttachmentDto { FileData = input.ExperienceCertificateAttach, OriginalName = input.ExperienceCertificateAttach?.Name, FileName = input.ExperienceCertificateAttach?.FileName, AttachmentTypeId = 4 });
+            }
+            if (input.ProfCertificateAttach != null)
+            {
+                input.UserAttachments.Add(new AttachmentDto { FileData = input.ProfCertificateAttach, OriginalName = input.ProfCertificateAttach?.Name, FileName = input.ProfCertificateAttach?.FileName, AttachmentTypeId = 5 });
+            }
 
             var files = input.UserAttachments.Select(a=> a.FileData).ToList();
             List<AttachmentDto> attachs = input.UserAttachments.ToList();
+            if(attachs != null && attachs.Count > 0)
              _fileService.CopyFileToCloud(ref attachs);
             //if (!res)
             //    throw new AppException(ExceptionEnum.CouldNotMoveFiles);
@@ -550,19 +640,7 @@ namespace MTWorkHR.Application.Services
 
 
 
-        private void AddAttachment(AttachmentDto attachment, int attachmentTypeId, IList<AttachmentDto> attachList)
-        {
-            if (attachment != null)
-            {
-                attachList.Add(new AttachmentDto
-                {
-                    FilePath = attachment.FilePath,
-                    OriginalName = attachment.OriginalName,
-                    FileName = attachment.FileName,
-                    AttachmentTypeId = attachmentTypeId
-                });
-            }
-        }
+     
         public async Task<BlobObject> Download(string filePath)
         {
             var file = await _fileService.Download(filePath);
@@ -652,8 +730,8 @@ namespace MTWorkHR.Application.Services
                 throw e;
             }
             // Return updated user
-            var userResponse = await GetById(input.Id);
-            return MapperObject.Mapper.Map<UserUpdateDto>(userResponse);
+            var userResponse = await GetByIdForUpdate(input.Id);
+            return userResponse;
         }
 
         private void ProcessAttachment(ICollection<UserAttachment> oldAttachments, IList<AttachmentDto> newAttachments, AttachmentDto attachment,int attachmentTypeId)
@@ -670,7 +748,7 @@ namespace MTWorkHR.Application.Services
             newAttachments.Add(new AttachmentDto
             {
                 FilePath = attachment.FilePath,
-                OriginalName = attachment.OriginalName,
+                OriginalName = string.IsNullOrEmpty( attachment.OriginalName) ? attachment.FileName : attachment.OriginalName,
                 FileName = attachment.FileName,
                 AttachmentTypeId = attachmentTypeId
             });

+ 1 - 1
MTWorkHR.Infrastructure/Entities/UserAttachment.cs

@@ -20,7 +20,7 @@ namespace MTWorkHR.Infrastructure.Entities
         public byte[] Content { get; set; }
 
         [MaxLength(250)]
-        public string OriginalName { get; set; }
+        public string? OriginalName { get; set; }
         public string? FilePath { get; set; }
         public string? ContentType { get; set; }
 

파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 7354 - 0
MTWorkHR.Infrastructure/Migrations/20250526104756_altrAttachmentOriginal.Designer.cs


+ 40 - 0
MTWorkHR.Infrastructure/Migrations/20250526104756_altrAttachmentOriginal.cs

@@ -0,0 +1,40 @@
+using Microsoft.EntityFrameworkCore.Migrations;
+
+#nullable disable
+
+namespace MTWorkHR.Infrastructure.Migrations
+{
+    /// <inheritdoc />
+    public partial class altrAttachmentOriginal : Migration
+    {
+        /// <inheritdoc />
+        protected override void Up(MigrationBuilder migrationBuilder)
+        {
+            migrationBuilder.AlterColumn<string>(
+                name: "OriginalName",
+                table: "UserAttachments",
+                type: "nvarchar(250)",
+                maxLength: 250,
+                nullable: true,
+                oldClrType: typeof(string),
+                oldType: "nvarchar(250)",
+                oldMaxLength: 250);
+        }
+
+        /// <inheritdoc />
+        protected override void Down(MigrationBuilder migrationBuilder)
+        {
+            migrationBuilder.AlterColumn<string>(
+                name: "OriginalName",
+                table: "UserAttachments",
+                type: "nvarchar(250)",
+                maxLength: 250,
+                nullable: false,
+                defaultValue: "",
+                oldClrType: typeof(string),
+                oldType: "nvarchar(250)",
+                oldMaxLength: 250,
+                oldNullable: true);
+        }
+    }
+}

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

@@ -6662,7 +6662,6 @@ namespace MTWorkHR.Infrastructure.Migrations
                         .HasColumnType("nvarchar(max)");
 
                     b.Property<string>("OriginalName")
-                        .IsRequired()
                         .HasMaxLength(250)
                         .HasColumnType("nvarchar(250)");