8 Commitit 700f32593b ... eb140b5d5b

Tekijä SHA1 Viesti Päivämäärä
  zinab_elgendy eb140b5d5b LastMessage 2 viikkoa sitten
  zinab_elgendy ec75cfbf67 Chat Change ChatUser 2 viikkoa sitten
  zinab_elgendy 8d75181c06 Chat merge 2 viikkoa sitten
  zinab_elgendy f2478b73e6 Contract 4 viikkoa sitten
  zinab_elgendy 5808a7c3c4 AttendanceDate save 1 kuukausi sitten
  zinab_elgendy a81eb4ac25 ignore updating attendanceDate 1 kuukausi sitten
  zinab_elgendy 3d529a8899 UserGetAll with companyName 1 kuukausi sitten
  zinab_elgendy f23dc0b1ee GetAll_FullName 1 kuukausi sitten
43 muutettua tiedostoa jossa 5743 lisäystä ja 53 poistoa
  1. 67 0
      MTWorkHR.API/Controllers/ContractController.cs
  2. 1 0
      MTWorkHR.Application/ApplicationServiceRegistration.cs
  3. 27 2
      MTWorkHR.Application/Chat/ChatHub.cs
  4. 25 0
      MTWorkHR.Application/Dtos/Contract/ContractAllowanceDto.cs
  5. 67 0
      MTWorkHR.Application/Dtos/Contract/ContractDto.cs
  6. 27 0
      MTWorkHR.Application/Dtos/Contract/ContractTaskAttachmentDto.cs
  7. 26 0
      MTWorkHR.Application/Dtos/Contract/ContractTaskDto.cs
  8. 27 0
      MTWorkHR.Application/Dtos/Contract/ProjectStageAttachmentDto.cs
  9. 26 0
      MTWorkHR.Application/Dtos/Contract/ProjectStageDto.cs
  10. 1 0
      MTWorkHR.Application/Dtos/Identity/CompanyUserDto.cs
  11. 1 0
      MTWorkHR.Application/Dtos/Identity/UserAllDto.cs
  12. 23 1
      MTWorkHR.Application/Dtos/User/ChatUserDto.cs
  13. 14 2
      MTWorkHR.Application/Mapper/MappingProfile.cs
  14. 104 0
      MTWorkHR.Application/Services/Contract/ContractService.cs
  15. 11 0
      MTWorkHR.Application/Services/Interfaces/IContractService.cs
  16. 1 0
      MTWorkHR.Application/Services/Interfaces/IUserService.cs
  17. 6 0
      MTWorkHR.Application/Services/User/AttendanceService.cs
  18. 26 0
      MTWorkHR.Application/Services/User/UserService.cs
  19. 55 31
      MTWorkHR.Core/Entities/Contract/Contract.cs
  20. 27 0
      MTWorkHR.Core/Entities/Contract/ContractAllowance.cs
  21. 27 0
      MTWorkHR.Core/Entities/Contract/ContractTask.cs
  22. 29 0
      MTWorkHR.Core/Entities/Contract/ContractTaskAttachment.cs
  23. 28 0
      MTWorkHR.Core/Entities/Contract/ProjectStage.cs
  24. 29 0
      MTWorkHR.Core/Entities/Contract/ProjectStageAttachment.cs
  25. 14 0
      MTWorkHR.Core/Global/Enum/BillingCycle.cs
  26. 16 0
      MTWorkHR.Core/Global/Enum/ContractStatusEnum.cs
  27. 16 0
      MTWorkHR.Core/Global/Enum/ContractTypeEnum.cs
  28. 14 0
      MTWorkHR.Core/Global/Enum/PaymentType.cs
  29. 15 0
      MTWorkHR.Core/Global/Enum/TerminateContractEnum.cs
  30. 14 0
      MTWorkHR.Core/Global/Enum/TypeOfWork.cs
  31. 14 0
      MTWorkHR.Core/Global/Enum/WorkingHours.cs
  32. 1 0
      MTWorkHR.Core/IRepositories/Chat/IChatMessageRepository.cs
  33. 16 0
      MTWorkHR.Core/IRepositories/Contract/IContractRepository.cs
  34. 1 0
      MTWorkHR.Core/IUnitOfWork/IUnitOfWork.cs
  35. 2 1
      MTWorkHR.Infrastructure/DBContext/HRDataContext.cs
  36. 2 1
      MTWorkHR.Infrastructure/InfrastructureServiceRegistration.cs
  37. 4122 0
      MTWorkHR.Infrastructure/Migrations/20241015091013_contractTbls.Designer.cs
  38. 275 0
      MTWorkHR.Infrastructure/Migrations/20241015091013_contractTbls.cs
  39. 498 0
      MTWorkHR.Infrastructure/Migrations/HRDataContextModelSnapshot.cs
  40. 8 0
      MTWorkHR.Infrastructure/Repositories/Chat/ChatMessageRepository.cs
  41. 37 0
      MTWorkHR.Infrastructure/Repositories/Contract/ContractRepository.cs
  42. 0 15
      MTWorkHR.Infrastructure/Repositories/EmployeeRepository.cs
  43. 3 0
      MTWorkHR.Infrastructure/UnitOfWork/UnitOfWork.cs

+ 67 - 0
MTWorkHR.API/Controllers/ContractController.cs

@@ -0,0 +1,67 @@
+using Microsoft.AspNetCore.Authorization;
+
+using Microsoft.AspNetCore.Http;
+using Microsoft.AspNetCore.Mvc;
+using MTWorkHR.Application.Filters;
+using MTWorkHR.Application.Identity;
+using MTWorkHR.Application.Models;
+using MTWorkHR.Application.Services.Interfaces;
+using MTWorkHR.Identity.Services;
+
+namespace MTWorkHR.API.Controllers
+{
+    [Route("api/[controller]")]
+    [ApiController]
+    [AppAuthorize]
+    public class ContractController : ControllerBase
+    {
+        private readonly IContractService _ContractService;
+        public ContractController(IContractService UserContractService)
+        {
+            this._ContractService = UserContractService;
+        }
+        [HttpGet("GetAll")]
+        [ProducesResponseType(StatusCodes.Status200OK)]
+
+        public async Task<ActionResult<List<ContractDto>>> GetAll([FromQuery] PagingInputDto pagingInput)
+        {
+            return Ok(await _ContractService.GetAll(pagingInput));
+        }
+        [HttpGet("Get")]
+        [ProducesResponseType(StatusCodes.Status200OK)]
+       // [AppAuthorize(Permissions = "Contract")]
+        public async Task<ActionResult<ContractDto>> Get(long ContractId)
+        {
+            return Ok(await _ContractService.GetById(ContractId));
+        }
+
+
+        [HttpPost("Create")]
+        [ProducesResponseType(StatusCodes.Status200OK)]
+       // [AppAuthorize(Permissions = "Contract.Create")]
+        public async Task<ActionResult<ContractDto>> Create([FromBody] ContractDto input)
+        {
+            return await _ContractService.Create(input);
+        }
+
+        [HttpPost("Update")]
+        [ProducesResponseType(StatusCodes.Status200OK)]
+       // [AppAuthorize(Permissions = "Contract.Update")]
+        public async Task Update([FromBody] ContractDto input)
+        {
+            await _ContractService.Update(input);
+        }
+
+        [HttpDelete("Delete")]
+        [ProducesResponseType(StatusCodes.Status200OK)]
+       // [AppAuthorize(Permissions = "Contract.Delete")]
+
+        public async Task Delete([FromQuery] long id)
+        {
+            await _ContractService.Delete(id);
+        }
+
+
+
+    }
+}

+ 1 - 0
MTWorkHR.Application/ApplicationServiceRegistration.cs

@@ -35,6 +35,7 @@ namespace MTWorkHR.Application
             services.AddScoped<IOrderRequestService, OrderRequestService>();
             services.AddScoped<ILookupService, LookupService>();
             services.AddScoped<ICompanyService, CompanyService>();
+            services.AddScoped<IContractService, ContractService>();
             services.AddScoped<IOTPService, OTPService>();
             services.AddScoped<ILogService<UserLog>, LogService<UserLog>>();
 

+ 27 - 2
MTWorkHR.Application/Chat/ChatHub.cs

@@ -45,12 +45,26 @@ namespace MTWorkHR.API.Chat
 
       
       
-        public async Task<List<UserAllDto>> GetAllCompanyEmployees()
+        public async Task<List<ChatUserDto>> GetAllCompanyEmployees()
         {
             var employees = await _userManager.GetUsersInRoleAsync("Employee");
             var CompanyId = GetAuthenticatedCompanyId();
             var res = employees.Where(e => e.CompanyId == CompanyId).ToList();
-            var response = MapperObject.Mapper.Map<List<UserAllDto>>(res);
+
+            var response = MapperObject.Mapper.Map<List<ChatUserDto>>(res);
+
+            var allConnections = await _unitOfWork.HubConnection.GetAllAsync();
+            var onlineUsers = allConnections.Item1
+                .Select(c => new { c.UserId, c.SignalrId }).ToList();
+            foreach(var emp in res)
+            {
+                var online = onlineUsers.FirstOrDefault(u=>  u.UserId == emp.Id);
+                var profileImg = "";
+                var lastMsg = "";
+                var lastMsgDate = "";
+                var unseenCount = 0;
+                var chatUser = new ChatUserDto(emp.Id, emp.FirstName + " " + emp.LastName, online?.SignalrId, emp.Email, online != null ? true : false, profileImg, unseenCount,lastMsg,lastMsgDate);
+            }
 
             return response;
         }
@@ -109,6 +123,17 @@ namespace MTWorkHR.API.Chat
 
             await Clients.Caller.SendAsync("PreviousMessages", messagesList);
         }
+
+
+        public async Task<ChatMessage> GetLastMessage()
+        {
+            var userId = Context.User.Identities.FirstOrDefault().FindFirst("uid")?.Value;
+            var allmessages = await _unitOfWork.ChatMessage.GetAllUserMessagesAsync(userId);
+            // Ensure the query is fully materialized before passing it to SignalR
+            var lastOne = allmessages.Item1.LastOrDefault();
+
+            return lastOne?? new ChatMessage();
+        }
         //----------------------------------------------------------------------
         //----------------------------------------------------------------------
         //----------------------------------------------------------------------

+ 25 - 0
MTWorkHR.Application/Dtos/Contract/ContractAllowanceDto.cs

@@ -0,0 +1,25 @@
+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;
+using MTWorkHR.Core.Global;
+
+namespace MTWorkHR.Application.Models
+{
+    public class ContractAllowanceDto : EntityDto
+    {
+
+        public long ContractId{ get; set; }
+        [Required]
+        public long AllowanceType { get; set; }
+        public string? AllowanceDesc { get; set; }
+        public long EntitlementPercent { get; set; }// اختيار (مبلغ – يكتب المبلغ)    أو  (نسبة من الراتب – ويظهر المبلغ توماتك)      
+        public long EntitlementAmount { get; set; }
+        public PaymentType PaymentType { get; set; }
+
+    }
+}

+ 67 - 0
MTWorkHR.Application/Dtos/Contract/ContractDto.cs

@@ -0,0 +1,67 @@
+using MTWorkHR.Application.Models;
+using MTWorkHR.Core.Entities.Base;
+using MTWorkHR.Core.Global;
+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;
+
+namespace MTWorkHR.Application.Models
+{
+    public class ContractDto : EntityDto
+    {
+        public ContractTypeEnum ContractTypeId { get; set; }
+
+        public long CompanyId { get; set; }
+        public string CompanyRepresentativeId { get; set; }
+       
+        public string UserId { get; set; }
+      
+        public int? JobId { get; set; }
+        public int? AcademicQualificationId { get; set; }
+        public int? SpecializationId { get; set; }
+        public int WorkCountryId { get; set; }
+        public int WorkStateId { get; set; }
+        //-------------------Scope of work-----------
+        public int? JobTitleId { get; set; }
+        public string? JobDescription{ get; set; }
+        [MaxLength(150)]
+        public string? JobNumber { get; set; } //ثابت و مأخوذ من المنصة
+        //----------------Contract data -------------------------
+        public DateTime? StartDate { get; set; }
+        public DateTime? EndDate { get; set; }
+        public int ContractDurationId { get; set; } //:  اختيار: شهري – ربعي – نصف سنوي – 3 ارباع – سنوي
+        public TypeOfWork TypeOfWork { get; set; } //: :   اختيار: عقد بدوام كامل -  عقد دوام جزئي   
+        public int VacationDays { get; set; } //اختيار: بدون – سنويا (رقم)
+        public int TrialPeriod { get; set; } // تجربة (ادخال: تلقائياً كل ربع سنوي أسبوع تلقائياً) آخر: تعديل
+        public TerminateContractEnum WhoCanTerminateContractInTrial { get; set; } //اختيار   الجميع – صاحب العمل – الموظف
+        public TerminateContractEnum WhoCanTerminateContract { get; set; }
+        public int NoticePeriodBeforeTermination { get; set; } //اختيار: بدون – تحديد (ادخال: تلقائياً مدة 10 أيام قبل انتهاء الاستحقاق) آخر: تعديل
+
+
+        //------Working time---------------
+        public string WorkingDays { get; set; } //:   اختيار متعدد الأيام سبت أحد اثنين..... (بحيث الأيام الأخرى تكون إجازة) 1,2,3,4,5
+        public WorkingHours WorkingHours { get; set; } //	يومي/ اسبوعي  
+        public DateTime? StartDailyWorkingHours { get; set; } // تحديد ساعات الدوام قائمة الساعات << التوقيت بحسب دولة صاحب العمل
+        public DateTime? EndDailyWorkingHours { get; set; } // تحديد ساعات الدوام قائمة الساعات << التوقيت بحسب دولة صاحب العمل
+
+        //----------Salary-----------------
+        [MaxLength(50)]
+        public string? Currency { get; set; }
+        public decimal? Salary{ get; set; }
+        public BillingCycle BillingCycle { get; set; }// 2 fortnightly, 4 Monthly
+
+
+        //---------Allowances----------------------
+        public bool IncludesAllAllowances { get; set; }
+        public List<ContractAllowanceDto>? FixedAllowances { get; set; }
+
+        //-------------------------------
+        public List<ContractTaskDto>? ContractTasks { get; set; }
+        public List<ProjectStageDto>? ProjectStages { get; set; }
+
+    }
+}

+ 27 - 0
MTWorkHR.Application/Dtos/Contract/ContractTaskAttachmentDto.cs

@@ -0,0 +1,27 @@
+using MTWorkHR.Core.Entities.Base;
+using System.ComponentModel.DataAnnotations.Schema;
+using System.ComponentModel.DataAnnotations;
+
+
+namespace MTWorkHR.Application.Models
+{
+    public class ContractTaskAttachmentDto : EntityDto
+    {
+        public long ContractTaskId { get; set; }
+
+        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 string? FilePath { get; set; }
+        public string? ContentType { get; set; }
+    }
+}

+ 26 - 0
MTWorkHR.Application/Dtos/Contract/ContractTaskDto.cs

@@ -0,0 +1,26 @@
+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.Application.Models
+{
+    public class ContractTaskDto : EntityDto
+    {
+
+        public long ContractId{ get; set; }
+        //public ContractDto? Contract { get; set; }
+        [Required]
+        [MaxLength(250)]
+        public string Title { get; set; }
+        public DateTime? StartDate{ get; set; }
+        public decimal? Amount { get; set; }
+        public string? ScopeOfWork { get; set; }
+        public List<ContractTaskAttachmentDto>? TaskAttachments { get; set; }
+
+    }
+}

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

@@ -0,0 +1,27 @@
+using MTWorkHR.Core.Entities.Base;
+using System.ComponentModel.DataAnnotations.Schema;
+using System.ComponentModel.DataAnnotations;
+
+
+namespace MTWorkHR.Application.Models
+{
+    public class ProjectStageAttachmentDto : EntityDto
+    {
+        public long ProjectStageId { get; set; }
+
+        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 string? FilePath { get; set; }
+        public string? ContentType { get; set; }
+    }
+}

+ 26 - 0
MTWorkHR.Application/Dtos/Contract/ProjectStageDto.cs

@@ -0,0 +1,26 @@
+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.Application.Models
+{
+    public class ProjectStageDto : EntityDto
+    {
+
+        public long ContractId{ get; set; }
+        [Required]
+        [MaxLength(250)]
+        public string Title { get; set; }
+        public DateTime? StartDate{ get; set; }
+        public DateTime? ExpectedEndDate { get; set; }
+        public decimal? AmountPercent { get; set; }
+        public string? ScopeOfWork { get; set; }
+        public List<ProjectStageAttachmentDto>? StageAttachments { get; set; }
+
+    }
+}

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

@@ -32,6 +32,7 @@ namespace MTWorkHR.Application.Models
       
         public decimal? TaxNumber { get; set; }
         public decimal? IncomeTaxValue { get; set; }
+        public string? Position { get; set; }
         public IList<AttachmentDto>? UserAttachments{ get; set; }
         public UserAddressDto? UserAddress{ get; set; }
 

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

@@ -34,6 +34,7 @@ namespace MTWorkHR.Application.Models
         public bool IsStopped { get; set; }
         public string? Position { get; set; }
         public long? CompanyId { get; set; }
+        public string? CompanyName { get; set; }
         public UserTypeEnum UserType { get; set; }
 
 

+ 23 - 1
MTWorkHR.Application/Dtos/User/ChatUserDto.cs

@@ -11,12 +11,34 @@ namespace MTWorkHR.Application.Models
         public string UserId { get; set; }
         public string UserName { get; set; }
         public string ConnectionId { get; set; } //signalrId
-
+        public string FirstName { get; set; }
+        public string LastName { get; set; }
+        public string FavoriteName { get; set; }
+        public string PhoneNumber { get; set; }
+        public string Email { get; set; }
+        public bool IsOnline { get; set; }
+        public string? ProfileImage { get; set; }
+        public string? LastMessage { get; set; }
+        public string? LastMessageDate { get; set; }
+        public int? UnseenCount { get; set; }
         public ChatUserDto(string someId, string someName, string someConnId)
         {
             UserId = someId;
             UserName = someName;
             ConnectionId = someConnId;
         }
+
+        public ChatUserDto(string userId, string userName, string ConnId, string email, bool isOnline, string profileImg, int? unseenCount,string lastMessage, string lastMessageDate)
+        {
+            UserId = userId;
+            UserName = userName;
+            ConnectionId = ConnId;
+            Email = email;
+            IsOnline = isOnline;
+            ProfileImage = profileImg;
+            UnseenCount = unseenCount;
+            LastMessageDate = lastMessageDate;
+            LastMessage = lastMessage;
+        }
     }
 }

+ 14 - 2
MTWorkHR.Application/Mapper/MappingProfile.cs

@@ -103,9 +103,9 @@ namespace MTWorkHR.Application.Mapper
             CreateMap<ProjectTeam, ProjectTeamDto>().ReverseMap().ForMember(d => d.CreateDate, o => o.Ignore());
 
             CreateMap<Attendance, AttendanceDto>().ForMember(d=> d.WeekDay , o=> o.MapFrom(s=> s.AttendanceDate.DayOfWeek))
-                .ForMember(d => d.TotalHours, o => o.MapFrom(s =>(s.CheckInTime.HasValue && s.CheckOutTime.HasValue) ? (s.CheckOutTime.Value - s.CheckInTime.Value).TotalHours:0)).ReverseMap()
-                .ForMember(d => d.CreateDate, o => o.Ignore());
+                .ForMember(d => d.TotalHours, o => o.MapFrom(s =>(s.CheckInTime.HasValue && s.CheckOutTime.HasValue) ? (s.CheckOutTime.Value - s.CheckInTime.Value).TotalHours:0));
 
+            CreateMap<AttendanceDto, Attendance>().ForMember(d => d.CreateDate, o => o.Ignore());
             CreateMap<OrderAllocation, OrderAllocationDto>().ReverseMap().ForMember(d => d.CreateDate, o => o.Ignore());
             CreateMap<OrderRequest, OrderRequestDto>().ReverseMap().ForMember(d => d.CreateDate, o => o.Ignore());
             CreateMap<OrderType, OrderTypeDto>().ReverseMap();
@@ -132,6 +132,18 @@ namespace MTWorkHR.Application.Mapper
             CreateMap<UserTaskStatus, UserTaskStatusDto>().ReverseMap();
             CreateMap<ChatMessageDto, ChatMessage>().ReverseMap();
             
+            //-----------Contract----
+            CreateMap<Contract, ContractDto>();
+            CreateMap<ContractDto, Contract>()
+                .ForMember(d => d.CreateDate, o => o.Ignore())
+                .ForMember(d => d.CreateUser, o => o.Ignore());
+            CreateMap<ContractAllowance, ContractAllowanceDto>().ReverseMap().ForMember(d => d.CreateDate, o => o.Ignore()).ForMember(d => d.CreateUser, o => o.Ignore()); ;
+            CreateMap<ContractTask, ContractTaskDto>().ReverseMap().ForMember(d => d.CreateDate, o => o.Ignore()).ForMember(d => d.CreateUser, o => o.Ignore()); ;
+            CreateMap<ContractTaskAttachment, ContractTaskAttachmentDto>().ReverseMap().ForMember(d => d.CreateDate, o => o.Ignore()).ForMember(d => d.CreateUser, o => o.Ignore()); ;
+            CreateMap<ProjectStage, ProjectStageDto>().ReverseMap().ForMember(d => d.CreateDate, o => o.Ignore()).ForMember(d => d.CreateUser, o => o.Ignore()); ;
+            CreateMap<ProjectStageAttachment, ProjectStageAttachmentDto>().ReverseMap().ForMember(d => d.CreateDate, o => o.Ignore()).ForMember(d => d.CreateUser, o => o.Ignore()); ;
+
+
         }
     }
 }

+ 104 - 0
MTWorkHR.Application/Services/Contract/ContractService.cs

@@ -0,0 +1,104 @@
+using Microsoft.EntityFrameworkCore;
+using MTWorkHR.Application.Identity;
+using MTWorkHR.Application.Mapper;
+using MTWorkHR.Application.Models;
+using MTWorkHR.Core.Global;
+using MTWorkHR.Core.UnitOfWork;
+using MTWorkHR.Application.Services.Interfaces;
+using MTWorkHR.Core.Entities;
+using System.Linq.Dynamic.Core;
+
+namespace MTWorkHR.Application.Services
+{
+    public class ContractService : BaseService<Contract, ContractDto, ContractDto>, IContractService
+    {
+        private readonly IUnitOfWork _unitOfWork;
+        private readonly IUserService _userService;
+        private readonly GlobalInfo _globalInfo;
+
+        public ContractService(IUnitOfWork unitOfWork, IUserService userService, GlobalInfo globalInfo) : base(unitOfWork)
+        {
+            _unitOfWork = unitOfWork;
+            _userService = userService;
+            _globalInfo = globalInfo;
+        }
+
+        public override async Task<ContractDto> GetById(long id)
+        {
+            var entity = await _unitOfWork.Contract.GetByIdWithAllChildren(id);
+            var response = MapperObject.Mapper.Map<ContractDto>(entity);
+            return response;
+        }
+       
+        public override async Task<ContractDto> Create(ContractDto input)
+        {
+            var entity = MapperObject.Mapper.Map<Contract>(input);
+
+            if (entity is null)
+            {
+                throw new AppException(ExceptionEnum.MapperIssue);
+            }
+
+            var team = await _unitOfWork.Contract.AddAsync(entity);
+            await _unitOfWork.CompleteAsync();
+
+            var response = MapperObject.Mapper.Map<ContractDto>(team);
+            return response;
+        }
+
+        //public override async Task<ContractDto> Update(ContractDto input)
+        //{
+        //    var entity = MapperObject.Mapper.Map<Contract>(input);
+
+        //    if (entity is null)
+        //    {
+        //        throw new AppException(ExceptionEnum.MapperIssue);
+        //    }
+
+        //    var contract = await _unitOfWork.Contract.upd(entity);
+        //    await _unitOfWork.CompleteAsync();
+
+
+        //    var response = Mapper.MapperObject.Mapper.Map<ContractDto>(entity);
+        //    return response;
+        //}
+        public override async Task<PagingResultDto<ContractDto>> GetAll(PagingInputDto PagingInputDto)
+        {
+            var res = await _unitOfWork.Contract.GetAllWithChildrenAsync();
+            var query = res.Item1;
+
+            if (_globalInfo.UserType != UserTypeEnum.Business)
+            {
+               // query = query.Where(m => m.ContractUsers != null && m.ContractUsers.Count > 0 && m.ContractUsers.Count(u=> u.AssignedUserId == _globalInfo.UserId) > 0);
+
+            }
+            if (PagingInputDto.Filter != null)
+            {
+                var filter = PagingInputDto.Filter;
+                query = query.Where(u => u.JobDescription.Contains(filter));
+            }
+
+            var order = query.OrderBy(PagingInputDto.OrderByField + " " + PagingInputDto.OrderType);
+
+            var page = order.Skip((PagingInputDto.PageNumber * PagingInputDto.PageSize) - PagingInputDto.PageSize).Take(PagingInputDto.PageSize);
+
+            var total = await query.CountAsync();
+
+            var list = MapperObject.Mapper
+                .Map<IList<ContractDto>>(await page.ToListAsync());
+
+            var response = new PagingResultDto<ContractDto>
+            {
+                Result = list,
+                Total = total
+            };
+
+            return response;
+        }
+
+       
+
+
+
+    }
+}

+ 11 - 0
MTWorkHR.Application/Services/Interfaces/IContractService.cs

@@ -0,0 +1,11 @@
+
+using MTWorkHR.Application.Models;
+using MTWorkHR.Core.Entities;
+using System.Threading.Tasks;
+
+namespace MTWorkHR.Application.Services.Interfaces
+{
+    public interface IContractService : IService<Contract, ContractDto, ContractDto>
+    {
+    }
+}

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

@@ -31,6 +31,7 @@ namespace MTWorkHR.Application.Identity
         Task<List<UserAllDto>> GetAllCompanyEmployees();
         Task<BlobObject> Download(string filePath);
         Task<UserDto> GetUserWithAttachmentById(string id);
+        Task<string> GetProfileImage(string userId);
 
     }
 }

+ 6 - 0
MTWorkHR.Application/Services/User/AttendanceService.cs

@@ -134,6 +134,8 @@ namespace MTWorkHR.Application.Services
 
         public override async Task<AttendanceDto> Create(AttendanceDto input)
         {
+            if (input.CheckInTime.HasValue)
+                input.AttendanceDate = input.CheckInTime.Value.Date;
             var oldEntity = await _unitOfWork.Attendance.GetAttendanceByUserId(input.UserId, input.AttendanceDate);
             if (oldEntity is null)
             {
@@ -159,6 +161,10 @@ namespace MTWorkHR.Application.Services
         public override async Task<AttendanceDto> Update(AttendanceDto input)
         {
             Attendance? entity = null;
+            if (input.CheckInTime.HasValue)
+                input.AttendanceDate = input.CheckInTime.Value.Date;
+            else if (input.CheckOutTime.HasValue)
+                input.AttendanceDate = input.CheckOutTime.Value.Date;
             if (input.Id > 0)
                 entity = await _unitOfWork.Attendance.GetByIdAsync(input.Id);
             else

+ 26 - 0
MTWorkHR.Application/Services/User/UserService.cs

@@ -23,6 +23,7 @@ using MTWorkHR.Infrastructure.EmailService;
 using Countries.NET.Database;
 using Microsoft.AspNetCore.Http;
 using System.Collections;
+using System.Linq;
 
 namespace MTWorkHR.Application.Services
 {
@@ -151,6 +152,19 @@ namespace MTWorkHR.Application.Services
 
             return response;
         }
+
+        public async Task<string> GetProfileImage(string userId)
+        {
+            string imagePath = null;
+            var user = await _userManager.Users.Include(u => u.UserAttachments)
+                .FirstOrDefaultAsync(x => x.Id == userId);
+            if (user != null)
+            {
+                var imageAtt = user.UserAttachments?.FirstOrDefault(a => a.AttachmentTypeId == 9);
+                imagePath = imageAtt != null ? imageAtt.FilePath : "";
+            }
+            return imagePath;
+        }
         //public async Task<List<UserDto>> GetAll(PagingInputDto pagingInput)
         //{
         //    var employees = await _userManager.GetUsersInRoleAsync("Employee");
@@ -164,6 +178,8 @@ namespace MTWorkHR.Application.Services
         //}
         public virtual async Task<PagingResultDto<UserAllDto>> GetAll(UserPagingInputDto PagingInputDto)
         {
+            var companies = await _unitOfWork.Company.GetAllAsync();
+           
             var query = _userManager.Users
                 .Include(u => u.Qualification)
                 .Include(u => u.JobTitle)
@@ -225,6 +241,16 @@ namespace MTWorkHR.Application.Services
 
             var list = MapperObject.Mapper.Map<IList<UserAllDto>>(result);
 
+            var ss = list
+             .Join(companies.Item1,               // Join the list with companies.Item1
+                   u => u.CompanyId,               // Key selector for User (CompanyId)
+                   c => c.Id,                      // Key selector for Company (Id)
+                   (u, c) => {                     // Project the join result
+                       u.CompanyName = c.CompanyName;     // Assuming 'Name' is the CompanyName in Company entity
+                       return u;                   // Return the updated UserAllDto with CompanyName filled
+                   })
+             .ToList();
+
             return new PagingResultDto<UserAllDto> { Result = list, Total = total };
         }
 

+ 55 - 31
MTWorkHR.Core/Entities/Contract/Contract.cs

@@ -1,58 +1,82 @@
 using MTWorkHR.Core.Entities.Base;
+using MTWorkHR.Core.Global;
 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;
 
-namespace MTWorkHR.Infrastructure.Entities
+namespace MTWorkHR.Core.Entities
 {
     public class Contract : FullAuditEntity, IHaveCompany
     {
-        public string FirstName { get; set; }
-        public string MiddleName { get; set; }
-        public string LastName { get; set; }
-        public string Email { get; set; }
+        public ContractTypeEnum ContractTypeId { get; set; }
+        public ContractStatusEnum ContractStatusId { get; set; }
 
-        public int Nationality { get; set; }
-        public int LivingCountry { get; set; }
+        public long CompanyId { get; set; }
+        public string CompanyRepresentativeId { get; set; }
+       
+        public string UserId { get; set; }
       
-        public bool IsVisaNeeded { get; set; } = false;
+        public int? JobId { get; set; }
+        public int? AcademicQualificationId { get; set; }
+        public int? SpecializationId { get; set; }
+        public int WorkCountryId { get; set; }
+        public int WorkStateId { get; set; }
+        public int ContractorTaxResidencyId { get; set; }
+        
+        //-------------------Scope of work-----------
+        public int? JobTitleId { get; set; }
+        public string? JobDescription{ get; set; }
+        [MaxLength(150)]
+        public string? JobNumber { get; set; } //ثابت و مأخوذ من المنصة
+        //----------------Contract data -------------------------
+        public DateTime? StartDate { get; set; }
+        public DateTime? EndDate { get; set; }
+        public int ContractDurationId { get; set; } //:  اختيار: شهري – ربعي – نصف سنوي – 3 ارباع – سنوي
+        public TypeOfWork TypeOfWork { get; set; } //: :   اختيار: عقد بدوام كامل -  عقد دوام جزئي   
+        public int VacationDays { get; set; } //اختيار: بدون – سنويا (رقم)
+        public int TrialPeriod { get; set; } // تجربة (ادخال: تلقائياً كل ربع سنوي أسبوع تلقائياً) آخر: تعديل
+        public TerminateContractEnum WhoCanTerminateContractInTrial { get; set; } //اختيار   الجميع – صاحب العمل – الموظف
+        public TerminateContractEnum WhoCanTerminateContract { get; set; }
+        public int NoticePeriodBeforeTermination { get; set; } //اختيار: بدون – تحديد (ادخال: تلقائياً مدة 10 أيام قبل انتهاء الاستحقاق) آخر: تعديل
 
 
-        public string? EducationLevel { get; set; }
-        public string? LinkedInLink { get; set; }
-        public int? NoOfDependent { get; set; }
-        //Job Details-----------------
-        public string? SeniorityLevel { get; set; }
-        public string? JobTitle { get; set; }
-        public string? JobScope { get; set; }
+        //------Working time---------------
+        public string WorkingDays { get; set; } //:   اختيار متعدد الأيام سبت أحد اثنين..... (بحيث الأيام الأخرى تكون إجازة) 1,2,3,4,5
+        public WorkingHours WorkingHours { get; set; } //	يومي/ اسبوعي  
+        public DateTime? StartDailyWorkingHours { get; set; } // تحديد ساعات الدوام قائمة الساعات << التوقيت بحسب دولة صاحب العمل
+        public DateTime? EndDailyWorkingHours { get; set; } // تحديد ساعات الدوام قائمة الساعات << التوقيت بحسب دولة صاحب العمل
 
+        //----------Salary-----------------
+        [MaxLength(50)]
+        public string? Currency { get; set; }
+        public decimal? Salary{ get; set; }
+        public BillingCycle BillingCycle { get; set; }// 2 fortnightly, 4 Monthly
 
-        //Compensation----------------------
 
+        //---------Allowances----------------------
+        public bool IncludesAllAllowances { get; set; }
+        public List<ContractAllowance>? FixedAllowances { get; set; }
 
-        public decimal? GrossAnnualBaseSalary { get; set; }
+        //-------------------------------
+        public List<ContractTask>? ContractTasks { get; set; }
+        public List<ProjectStage>? ProjectStages { get; set; }
 
-        public bool? AddSigningBonus { get; set; }
-        public bool? AddAnnualVariableCompensation { get; set; }
-        public bool? FixedAllowances { get; set; }
-        public DateTime? StartDate { get; set; }
 
+        //  public decimal? GrossAnnualBaseSalary { get; set; }
 
-        public bool FullTime { get; set; } = true; //full-time that will be 40 hours , part-time will be add it manually
-        public int EmployeeTypeHours { get; set; } = 40; //full-time that will be 40 hours , part-time will be add it manually
+        //  public bool? AddSigningBonus { get; set; }
+        // public bool? AddAnnualVariableCompensation { get; set; }
 
-        public int PaidVacationDays { get; set; }
-        public int SickDays { get; set; }
-        public bool EmploymentTerms { get; set; }
-        public int ProbationPeriod { get; set; }
-        public int Gender { get; set; }
-        public DateTime? DateOfBirth { get; set; }
+        //public bool FullTime { get; set; } = true; //full-time that will be 40 hours , part-time will be add it manually
+        //public int EmployeeTypeHours { get; set; } = 40; //full-time that will be 40 hours , part-time will be add it manually
 
+        //public int PaidVacationDays { get; set; }
+        //public int SickDays { get; set; }
+        //public bool EmploymentTerms { get; set; }
 
-        public bool IsSkilled { get; set; }
-        public long CompanyId { get ; set; }
     }
 }

+ 27 - 0
MTWorkHR.Core/Entities/Contract/ContractAllowance.cs

@@ -0,0 +1,27 @@
+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;
+using MTWorkHR.Core.Global;
+
+namespace MTWorkHR.Core.Entities
+{
+    public class ContractAllowance : AuditEntity
+    {
+
+        public long ContractId{ get; set; }
+        [ForeignKey("ContractId")]
+        public Contract? Contract { get; set; }
+        [Required]
+        public long AllowanceType { get; set; }
+        public string? AllowanceDesc { get; set; }
+        public long EntitlementPercent { get; set; }// اختيار (مبلغ – يكتب المبلغ)    أو  (نسبة من الراتب – ويظهر المبلغ توماتك)      
+        public long EntitlementAmount { get; set; }
+        public PaymentType PaymentType { get; set; }
+
+    }
+}

+ 27 - 0
MTWorkHR.Core/Entities/Contract/ContractTask.cs

@@ -0,0 +1,27 @@
+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 ContractTask : AuditEntity
+    {
+
+        public long ContractId{ get; set; }
+        [ForeignKey("ContractId")]
+        public Contract? Contract { get; set; }
+        [Required]
+        [MaxLength(250)]
+        public string Title { get; set; }
+        public DateTime? StartDate{ get; set; }
+        public decimal? Amount { get; set; }
+        public string? ScopeOfWork { get; set; }
+        public List<ContractTaskAttachment>? TaskAttachments { get; set; }
+
+    }
+}

+ 29 - 0
MTWorkHR.Core/Entities/Contract/ContractTaskAttachment.cs

@@ -0,0 +1,29 @@
+using MTWorkHR.Core.Entities.Base;
+using System.ComponentModel.DataAnnotations.Schema;
+using System.ComponentModel.DataAnnotations;
+
+
+namespace MTWorkHR.Core.Entities
+{
+    public class ContractTaskAttachment : AuditEntity
+    {
+        public long ContractTaskId { get; set; }
+
+        [ForeignKey("ContractTaskId")]
+        public ContractTask ContractTask { get; set; }
+        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 string? FilePath { get; set; }
+        public string? ContentType { get; set; }
+    }
+}

+ 28 - 0
MTWorkHR.Core/Entities/Contract/ProjectStage.cs

@@ -0,0 +1,28 @@
+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 ProjectStage : AuditEntity
+    {
+
+        public long ContractId{ get; set; }
+        [ForeignKey("ContractId")]
+        public Contract? Contract { get; set; }
+        [Required]
+        [MaxLength(250)]
+        public string Title { get; set; }
+        public DateTime? StartDate{ get; set; }
+        public DateTime? ExpectedEndDate { get; set; }
+        public decimal? AmountPercent { get; set; }
+        public string? ScopeOfWork { get; set; }
+        public List<ProjectStageAttachment>? StageAttachments { get; set; }
+
+    }
+}

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

@@ -0,0 +1,29 @@
+using MTWorkHR.Core.Entities.Base;
+using System.ComponentModel.DataAnnotations.Schema;
+using System.ComponentModel.DataAnnotations;
+
+
+namespace MTWorkHR.Core.Entities
+{
+    public class ProjectStageAttachment : AuditEntity
+    {
+        public long ProjectStageId { get; set; }
+
+        [ForeignKey("ProjectStageId")]
+        public ProjectStage ProjectStage { get; set; }
+        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 string? FilePath { get; set; }
+        public string? ContentType { get; set; }
+    }
+}

+ 14 - 0
MTWorkHR.Core/Global/Enum/BillingCycle.cs

@@ -0,0 +1,14 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace MTWorkHR.Core.Global
+{
+    public enum BillingCycle
+    {
+        Monthly,
+        Fortnightly
+    }
+}

+ 16 - 0
MTWorkHR.Core/Global/Enum/ContractStatusEnum.cs

@@ -0,0 +1,16 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace MTWorkHR.Core.Global
+{
+    public enum ContractStatusEnum
+    {
+        Initiated = 1,
+        Reviewed= 2,
+        Approved= 3,
+        Canceled= 4,
+    }
+}

+ 16 - 0
MTWorkHR.Core/Global/Enum/ContractTypeEnum.cs

@@ -0,0 +1,16 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace MTWorkHR.Core.Global
+{
+    public enum ContractTypeEnum
+    {
+        EmployeeContract = 1,
+        FixedPayContract = 2,
+        PerProjectContract = 3,
+        PerTaskContract = 4,
+    }
+}

+ 14 - 0
MTWorkHR.Core/Global/Enum/PaymentType.cs

@@ -0,0 +1,14 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace MTWorkHR.Core.Global
+{
+    public enum PaymentType
+    {
+        OneTime,
+        ContinuousWithSalary
+    }
+}

+ 15 - 0
MTWorkHR.Core/Global/Enum/TerminateContractEnum.cs

@@ -0,0 +1,15 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace MTWorkHR.Core.Global
+{
+    public enum TerminateContractEnum
+    {
+        All = 1,
+        WorkOwner = 2,
+        Employee = 3
+    }
+}

+ 14 - 0
MTWorkHR.Core/Global/Enum/TypeOfWork.cs

@@ -0,0 +1,14 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace MTWorkHR.Core.Global
+{
+    public enum TypeOfWork
+    {
+        FullTime,
+        PartTime
+    }
+}

+ 14 - 0
MTWorkHR.Core/Global/Enum/WorkingHours.cs

@@ -0,0 +1,14 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace MTWorkHR.Core.Global
+{
+    public enum WorkingHours
+    {
+        Daily,
+        Weekly,
+    }
+}

+ 1 - 0
MTWorkHR.Core/IRepositories/Chat/IChatMessageRepository.cs

@@ -12,5 +12,6 @@ namespace MTWorkHR.Core.IRepositories
     {
         Task<ChatMessage> GetByIdWithAllChildren(long id);
         Task<Tuple<IQueryable<ChatMessage>, int>> GetAllWithChildrenAsync(string userId, string contactId);
+        Task<Tuple<IQueryable<ChatMessage>, int>> GetAllUserMessagesAsync(string userId);
     }
 }

+ 16 - 0
MTWorkHR.Core/IRepositories/Contract/IContractRepository.cs

@@ -0,0 +1,16 @@
+using MTWorkHR.Core.Entities;
+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 IContractRepository : IRepository<Contract>
+    {
+        Task<Contract> GetByIdWithAllChildren(long id);
+        Task<Tuple<IQueryable<Contract>, int>> GetAllWithChildrenAsync();
+    }
+}

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

@@ -36,6 +36,7 @@ namespace MTWorkHR.Core.UnitOfWork
         ILoginOTPRepository LoginOTP { get; }
 
         IChatMessageRepository ChatMessage { get; }
+        IContractRepository Contract { get; }
         IHubConnectionRepository HubConnection { get; }
 
         Task<int> CompleteAsync();

+ 2 - 1
MTWorkHR.Infrastructure/DBContext/HRDataContext.cs

@@ -51,8 +51,9 @@ namespace MTWorkHR.Infrastructure.DBContext
         public DbSet<JobTitle> JobTitles { get; set; }
         public DbSet<LoginOTP> LoginOTPs { get; set; }
         public DbSet<City> Cities { get; set; }
+        //-----------
+        public DbSet<Contract> Contracts { get; set; }
 
-        
         //------------------------Logs------------------------
         public DbSet<UserLog> UserLogs { get; set; }
         public DbSet<AuthLog> AuthLogs { get; set; }

+ 2 - 1
MTWorkHR.Infrastructure/InfrastructureServiceRegistration.cs

@@ -103,6 +103,8 @@ namespace MTWorkHR.Infrastructure
             services.AddScoped(typeof(ICityRepository), typeof(CityRepository));
             services.AddScoped(typeof(IProjectTeamRepository), typeof(ProjectTeamRepository));
             services.AddScoped(typeof(IChatMessageRepository), typeof(ChatMessageRepository));
+            services.AddScoped(typeof(IContractRepository), typeof(ContractRepository));
+
             services.AddScoped(typeof(IHubConnectionRepository), typeof(HubConnectionRepository));
             
 
@@ -118,7 +120,6 @@ namespace MTWorkHR.Infrastructure
             services.AddScoped<ApplicationUserManager>();
             services.AddScoped<GlobalInfo>();
 
-            services.AddScoped<IEmployeeRepository, EmployeeRepository>();
 
             //services.AddScoped(typeof(IAppLogger<>), typeof(LoggerAdapter<>));
             return services;

Tiedoston diff-näkymää rajattu, sillä se on liian suuri
+ 4122 - 0
MTWorkHR.Infrastructure/Migrations/20241015091013_contractTbls.Designer.cs


+ 275 - 0
MTWorkHR.Infrastructure/Migrations/20241015091013_contractTbls.cs

@@ -0,0 +1,275 @@
+using System;
+using Microsoft.EntityFrameworkCore.Migrations;
+
+#nullable disable
+
+namespace MTWorkHR.Infrastructure.Migrations
+{
+    /// <inheritdoc />
+    public partial class contractTbls : Migration
+    {
+        /// <inheritdoc />
+        protected override void Up(MigrationBuilder migrationBuilder)
+        {
+            migrationBuilder.CreateTable(
+                name: "Contracts",
+                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),
+                    IsDeleted = table.Column<bool>(type: "bit", nullable: false),
+                    DeleteUserId = table.Column<string>(type: "nvarchar(450)", maxLength: 450, nullable: true),
+                    ContractTypeId = table.Column<int>(type: "int", nullable: false),
+                    CompanyId = table.Column<long>(type: "bigint", nullable: false),
+                    CompanyRepresentativeId = table.Column<string>(type: "nvarchar(max)", nullable: false),
+                    UserId = table.Column<string>(type: "nvarchar(max)", nullable: false),
+                    JobId = table.Column<int>(type: "int", nullable: true),
+                    AcademicQualificationId = table.Column<int>(type: "int", nullable: true),
+                    SpecializationId = table.Column<int>(type: "int", nullable: true),
+                    WorkCountryId = table.Column<int>(type: "int", nullable: false),
+                    WorkStateId = table.Column<int>(type: "int", nullable: false),
+                    JobTitleId = table.Column<int>(type: "int", nullable: true),
+                    JobDescription = table.Column<string>(type: "nvarchar(max)", nullable: true),
+                    JobNumber = table.Column<string>(type: "nvarchar(150)", maxLength: 150, nullable: true),
+                    StartDate = table.Column<DateTime>(type: "datetime2", nullable: true),
+                    EndDate = table.Column<DateTime>(type: "datetime2", nullable: true),
+                    ContractDurationId = table.Column<int>(type: "int", nullable: false),
+                    TypeOfWork = table.Column<int>(type: "int", nullable: false),
+                    VacationDays = table.Column<int>(type: "int", nullable: false),
+                    TrialPeriod = table.Column<int>(type: "int", nullable: false),
+                    WhoCanTerminateContractInTrial = table.Column<int>(type: "int", nullable: false),
+                    WhoCanTerminateContract = table.Column<int>(type: "int", nullable: false),
+                    NoticePeriodBeforeTermination = table.Column<int>(type: "int", nullable: false),
+                    WorkingDays = table.Column<string>(type: "nvarchar(max)", nullable: false),
+                    WorkingHours = table.Column<int>(type: "int", nullable: false),
+                    StartDailyWorkingHours = table.Column<DateTime>(type: "datetime2", nullable: true),
+                    EndDailyWorkingHours = table.Column<DateTime>(type: "datetime2", nullable: true),
+                    Currency = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: true),
+                    Salary = table.Column<decimal>(type: "decimal(18,2)", nullable: true),
+                    BillingCycle = table.Column<int>(type: "int", nullable: false),
+                    IncludesAllAllowances = table.Column<bool>(type: "bit", nullable: false)
+                },
+                constraints: table =>
+                {
+                    table.PrimaryKey("PK_Contracts", x => x.Id);
+                });
+
+            migrationBuilder.CreateTable(
+                name: "ContractAllowance",
+                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),
+                    ContractId = table.Column<long>(type: "bigint", nullable: false),
+                    AllowanceType = table.Column<long>(type: "bigint", nullable: false),
+                    AllowanceDesc = table.Column<string>(type: "nvarchar(max)", nullable: true),
+                    EntitlementPercent = table.Column<long>(type: "bigint", nullable: false),
+                    EntitlementAmount = table.Column<long>(type: "bigint", nullable: false),
+                    PaymentType = table.Column<int>(type: "int", nullable: false)
+                },
+                constraints: table =>
+                {
+                    table.PrimaryKey("PK_ContractAllowance", x => x.Id);
+                    table.ForeignKey(
+                        name: "FK_ContractAllowance_Contracts_ContractId",
+                        column: x => x.ContractId,
+                        principalTable: "Contracts",
+                        principalColumn: "Id",
+                        onDelete: ReferentialAction.Cascade);
+                });
+
+            migrationBuilder.CreateTable(
+                name: "ContractTask",
+                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),
+                    ContractId = table.Column<long>(type: "bigint", nullable: false),
+                    Title = table.Column<string>(type: "nvarchar(250)", maxLength: 250, nullable: false),
+                    StartDate = table.Column<DateTime>(type: "datetime2", nullable: true),
+                    Amount = table.Column<decimal>(type: "decimal(18,2)", nullable: true),
+                    ScopeOfWork = table.Column<string>(type: "nvarchar(max)", nullable: true)
+                },
+                constraints: table =>
+                {
+                    table.PrimaryKey("PK_ContractTask", x => x.Id);
+                    table.ForeignKey(
+                        name: "FK_ContractTask_Contracts_ContractId",
+                        column: x => x.ContractId,
+                        principalTable: "Contracts",
+                        principalColumn: "Id",
+                        onDelete: ReferentialAction.Cascade);
+                });
+
+            migrationBuilder.CreateTable(
+                name: "ProjectStage",
+                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),
+                    ContractId = table.Column<long>(type: "bigint", nullable: false),
+                    Title = table.Column<string>(type: "nvarchar(250)", maxLength: 250, nullable: false),
+                    StartDate = table.Column<DateTime>(type: "datetime2", nullable: true),
+                    ExpectedEndDate = table.Column<DateTime>(type: "datetime2", nullable: true),
+                    AmountPercent = table.Column<decimal>(type: "decimal(18,2)", nullable: true),
+                    ScopeOfWork = table.Column<string>(type: "nvarchar(max)", nullable: true)
+                },
+                constraints: table =>
+                {
+                    table.PrimaryKey("PK_ProjectStage", x => x.Id);
+                    table.ForeignKey(
+                        name: "FK_ProjectStage_Contracts_ContractId",
+                        column: x => x.ContractId,
+                        principalTable: "Contracts",
+                        principalColumn: "Id",
+                        onDelete: ReferentialAction.Cascade);
+                });
+
+            migrationBuilder.CreateTable(
+                name: "ContractTaskAttachment",
+                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),
+                    ContractTaskId = table.Column<long>(type: "bigint", nullable: false),
+                    AttachmentTypeId = table.Column<long>(type: "bigint", nullable: true),
+                    FileName = table.Column<string>(type: "nvarchar(250)", maxLength: 250, nullable: true),
+                    OriginalName = table.Column<string>(type: "nvarchar(250)", maxLength: 250, nullable: true),
+                    Content = table.Column<byte[]>(type: "varbinary(max)", nullable: false),
+                    FilePath = table.Column<string>(type: "nvarchar(max)", nullable: true),
+                    ContentType = table.Column<string>(type: "nvarchar(max)", nullable: true)
+                },
+                constraints: table =>
+                {
+                    table.PrimaryKey("PK_ContractTaskAttachment", x => x.Id);
+                    table.ForeignKey(
+                        name: "FK_ContractTaskAttachment_AttachmentTypes_AttachmentTypeId",
+                        column: x => x.AttachmentTypeId,
+                        principalTable: "AttachmentTypes",
+                        principalColumn: "Id");
+                    table.ForeignKey(
+                        name: "FK_ContractTaskAttachment_ContractTask_ContractTaskId",
+                        column: x => x.ContractTaskId,
+                        principalTable: "ContractTask",
+                        principalColumn: "Id",
+                        onDelete: ReferentialAction.Cascade);
+                });
+
+            migrationBuilder.CreateTable(
+                name: "ProjectStageAttachment",
+                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),
+                    ProjectStageId = table.Column<long>(type: "bigint", nullable: false),
+                    AttachmentTypeId = table.Column<long>(type: "bigint", nullable: true),
+                    FileName = table.Column<string>(type: "nvarchar(250)", maxLength: 250, nullable: true),
+                    OriginalName = table.Column<string>(type: "nvarchar(250)", maxLength: 250, nullable: true),
+                    Content = table.Column<byte[]>(type: "varbinary(max)", nullable: false),
+                    FilePath = table.Column<string>(type: "nvarchar(max)", nullable: true),
+                    ContentType = table.Column<string>(type: "nvarchar(max)", nullable: true)
+                },
+                constraints: table =>
+                {
+                    table.PrimaryKey("PK_ProjectStageAttachment", x => x.Id);
+                    table.ForeignKey(
+                        name: "FK_ProjectStageAttachment_AttachmentTypes_AttachmentTypeId",
+                        column: x => x.AttachmentTypeId,
+                        principalTable: "AttachmentTypes",
+                        principalColumn: "Id");
+                    table.ForeignKey(
+                        name: "FK_ProjectStageAttachment_ProjectStage_ProjectStageId",
+                        column: x => x.ProjectStageId,
+                        principalTable: "ProjectStage",
+                        principalColumn: "Id",
+                        onDelete: ReferentialAction.Cascade);
+                });
+
+            migrationBuilder.CreateIndex(
+                name: "IX_ContractAllowance_ContractId",
+                table: "ContractAllowance",
+                column: "ContractId");
+
+            migrationBuilder.CreateIndex(
+                name: "IX_Contracts_CompanyId",
+                table: "Contracts",
+                column: "CompanyId");
+
+            migrationBuilder.CreateIndex(
+                name: "IX_ContractTask_ContractId",
+                table: "ContractTask",
+                column: "ContractId");
+
+            migrationBuilder.CreateIndex(
+                name: "IX_ContractTaskAttachment_AttachmentTypeId",
+                table: "ContractTaskAttachment",
+                column: "AttachmentTypeId");
+
+            migrationBuilder.CreateIndex(
+                name: "IX_ContractTaskAttachment_ContractTaskId",
+                table: "ContractTaskAttachment",
+                column: "ContractTaskId");
+
+            migrationBuilder.CreateIndex(
+                name: "IX_ProjectStage_ContractId",
+                table: "ProjectStage",
+                column: "ContractId");
+
+            migrationBuilder.CreateIndex(
+                name: "IX_ProjectStageAttachment_AttachmentTypeId",
+                table: "ProjectStageAttachment",
+                column: "AttachmentTypeId");
+
+            migrationBuilder.CreateIndex(
+                name: "IX_ProjectStageAttachment_ProjectStageId",
+                table: "ProjectStageAttachment",
+                column: "ProjectStageId");
+        }
+
+        /// <inheritdoc />
+        protected override void Down(MigrationBuilder migrationBuilder)
+        {
+            migrationBuilder.DropTable(
+                name: "ContractAllowance");
+
+            migrationBuilder.DropTable(
+                name: "ContractTaskAttachment");
+
+            migrationBuilder.DropTable(
+                name: "ProjectStageAttachment");
+
+            migrationBuilder.DropTable(
+                name: "ContractTask");
+
+            migrationBuilder.DropTable(
+                name: "ProjectStage");
+
+            migrationBuilder.DropTable(
+                name: "Contracts");
+        }
+    }
+}

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

@@ -514,6 +514,304 @@ namespace MTWorkHR.Infrastructure.Migrations
                     b.ToTable("Companies");
                 });
 
+            modelBuilder.Entity("MTWorkHR.Core.Entities.Contract", b =>
+                {
+                    b.Property<long>("Id")
+                        .ValueGeneratedOnAdd()
+                        .HasColumnType("bigint")
+                        .HasColumnOrder(0);
+
+                    SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<long>("Id"));
+
+                    b.Property<int?>("AcademicQualificationId")
+                        .HasColumnType("int");
+
+                    b.Property<int>("BillingCycle")
+                        .HasColumnType("int");
+
+                    b.Property<long>("CompanyId")
+                        .HasColumnType("bigint");
+
+                    b.Property<string>("CompanyRepresentativeId")
+                        .IsRequired()
+                        .HasColumnType("nvarchar(max)");
+
+                    b.Property<int>("ContractDurationId")
+                        .HasColumnType("int");
+
+                    b.Property<int>("ContractTypeId")
+                        .HasColumnType("int");
+
+                    b.Property<DateTime>("CreateDate")
+                        .HasColumnType("datetime2")
+                        .HasColumnOrder(3);
+
+                    b.Property<string>("CreateUser")
+                        .HasMaxLength(450)
+                        .HasColumnType("nvarchar(450)")
+                        .HasColumnOrder(1);
+
+                    b.Property<string>("Currency")
+                        .HasMaxLength(50)
+                        .HasColumnType("nvarchar(50)");
+
+                    b.Property<string>("DeleteUserId")
+                        .HasMaxLength(450)
+                        .HasColumnType("nvarchar(450)")
+                        .HasColumnOrder(8);
+
+                    b.Property<DateTime?>("EndDailyWorkingHours")
+                        .HasColumnType("datetime2");
+
+                    b.Property<DateTime?>("EndDate")
+                        .HasColumnType("datetime2");
+
+                    b.Property<bool>("IncludesAllAllowances")
+                        .HasColumnType("bit");
+
+                    b.Property<bool>("IsDeleted")
+                        .HasColumnType("bit")
+                        .HasColumnOrder(7);
+
+                    b.Property<string>("JobDescription")
+                        .HasColumnType("nvarchar(max)");
+
+                    b.Property<int?>("JobId")
+                        .HasColumnType("int");
+
+                    b.Property<string>("JobNumber")
+                        .HasMaxLength(150)
+                        .HasColumnType("nvarchar(150)");
+
+                    b.Property<int?>("JobTitleId")
+                        .HasColumnType("int");
+
+                    b.Property<int>("NoticePeriodBeforeTermination")
+                        .HasColumnType("int");
+
+                    b.Property<decimal?>("Salary")
+                        .HasColumnType("decimal(18,2)");
+
+                    b.Property<int?>("SpecializationId")
+                        .HasColumnType("int");
+
+                    b.Property<DateTime?>("StartDailyWorkingHours")
+                        .HasColumnType("datetime2");
+
+                    b.Property<DateTime?>("StartDate")
+                        .HasColumnType("datetime2");
+
+                    b.Property<int>("TrialPeriod")
+                        .HasColumnType("int");
+
+                    b.Property<int>("TypeOfWork")
+                        .HasColumnType("int");
+
+                    b.Property<DateTime?>("UpdateDate")
+                        .HasColumnType("datetime2")
+                        .HasColumnOrder(4);
+
+                    b.Property<string>("UpdateUser")
+                        .HasMaxLength(450)
+                        .HasColumnType("nvarchar(450)")
+                        .HasColumnOrder(2);
+
+                    b.Property<string>("UserId")
+                        .IsRequired()
+                        .HasColumnType("nvarchar(max)");
+
+                    b.Property<int>("VacationDays")
+                        .HasColumnType("int");
+
+                    b.Property<int>("WhoCanTerminateContract")
+                        .HasColumnType("int");
+
+                    b.Property<int>("WhoCanTerminateContractInTrial")
+                        .HasColumnType("int");
+
+                    b.Property<int>("WorkCountryId")
+                        .HasColumnType("int");
+
+                    b.Property<int>("WorkStateId")
+                        .HasColumnType("int");
+
+                    b.Property<string>("WorkingDays")
+                        .IsRequired()
+                        .HasColumnType("nvarchar(max)");
+
+                    b.Property<int>("WorkingHours")
+                        .HasColumnType("int");
+
+                    b.HasKey("Id");
+
+                    b.HasIndex("CompanyId");
+
+                    b.ToTable("Contracts");
+                });
+
+            modelBuilder.Entity("MTWorkHR.Core.Entities.ContractAllowance", b =>
+                {
+                    b.Property<long>("Id")
+                        .ValueGeneratedOnAdd()
+                        .HasColumnType("bigint")
+                        .HasColumnOrder(0);
+
+                    SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<long>("Id"));
+
+                    b.Property<string>("AllowanceDesc")
+                        .HasColumnType("nvarchar(max)");
+
+                    b.Property<long>("AllowanceType")
+                        .HasColumnType("bigint");
+
+                    b.Property<long>("ContractId")
+                        .HasColumnType("bigint");
+
+                    b.Property<DateTime>("CreateDate")
+                        .HasColumnType("datetime2")
+                        .HasColumnOrder(3);
+
+                    b.Property<string>("CreateUser")
+                        .HasMaxLength(450)
+                        .HasColumnType("nvarchar(450)")
+                        .HasColumnOrder(1);
+
+                    b.Property<long>("EntitlementAmount")
+                        .HasColumnType("bigint");
+
+                    b.Property<long>("EntitlementPercent")
+                        .HasColumnType("bigint");
+
+                    b.Property<int>("PaymentType")
+                        .HasColumnType("int");
+
+                    b.Property<DateTime?>("UpdateDate")
+                        .HasColumnType("datetime2")
+                        .HasColumnOrder(4);
+
+                    b.Property<string>("UpdateUser")
+                        .HasMaxLength(450)
+                        .HasColumnType("nvarchar(450)")
+                        .HasColumnOrder(2);
+
+                    b.HasKey("Id");
+
+                    b.HasIndex("ContractId");
+
+                    b.ToTable("ContractAllowance");
+                });
+
+            modelBuilder.Entity("MTWorkHR.Core.Entities.ContractTask", b =>
+                {
+                    b.Property<long>("Id")
+                        .ValueGeneratedOnAdd()
+                        .HasColumnType("bigint")
+                        .HasColumnOrder(0);
+
+                    SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<long>("Id"));
+
+                    b.Property<decimal?>("Amount")
+                        .HasColumnType("decimal(18,2)");
+
+                    b.Property<long>("ContractId")
+                        .HasColumnType("bigint");
+
+                    b.Property<DateTime>("CreateDate")
+                        .HasColumnType("datetime2")
+                        .HasColumnOrder(3);
+
+                    b.Property<string>("CreateUser")
+                        .HasMaxLength(450)
+                        .HasColumnType("nvarchar(450)")
+                        .HasColumnOrder(1);
+
+                    b.Property<string>("ScopeOfWork")
+                        .HasColumnType("nvarchar(max)");
+
+                    b.Property<DateTime?>("StartDate")
+                        .HasColumnType("datetime2");
+
+                    b.Property<string>("Title")
+                        .IsRequired()
+                        .HasMaxLength(250)
+                        .HasColumnType("nvarchar(250)");
+
+                    b.Property<DateTime?>("UpdateDate")
+                        .HasColumnType("datetime2")
+                        .HasColumnOrder(4);
+
+                    b.Property<string>("UpdateUser")
+                        .HasMaxLength(450)
+                        .HasColumnType("nvarchar(450)")
+                        .HasColumnOrder(2);
+
+                    b.HasKey("Id");
+
+                    b.HasIndex("ContractId");
+
+                    b.ToTable("ContractTask");
+                });
+
+            modelBuilder.Entity("MTWorkHR.Core.Entities.ContractTaskAttachment", b =>
+                {
+                    b.Property<long>("Id")
+                        .ValueGeneratedOnAdd()
+                        .HasColumnType("bigint")
+                        .HasColumnOrder(0);
+
+                    SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<long>("Id"));
+
+                    b.Property<long?>("AttachmentTypeId")
+                        .HasColumnType("bigint");
+
+                    b.Property<byte[]>("Content")
+                        .IsRequired()
+                        .HasColumnType("varbinary(max)");
+
+                    b.Property<string>("ContentType")
+                        .HasColumnType("nvarchar(max)");
+
+                    b.Property<long>("ContractTaskId")
+                        .HasColumnType("bigint");
+
+                    b.Property<DateTime>("CreateDate")
+                        .HasColumnType("datetime2")
+                        .HasColumnOrder(3);
+
+                    b.Property<string>("CreateUser")
+                        .HasMaxLength(450)
+                        .HasColumnType("nvarchar(450)")
+                        .HasColumnOrder(1);
+
+                    b.Property<string>("FileName")
+                        .HasMaxLength(250)
+                        .HasColumnType("nvarchar(250)");
+
+                    b.Property<string>("FilePath")
+                        .HasColumnType("nvarchar(max)");
+
+                    b.Property<string>("OriginalName")
+                        .HasMaxLength(250)
+                        .HasColumnType("nvarchar(250)");
+
+                    b.Property<DateTime?>("UpdateDate")
+                        .HasColumnType("datetime2")
+                        .HasColumnOrder(4);
+
+                    b.Property<string>("UpdateUser")
+                        .HasMaxLength(450)
+                        .HasColumnType("nvarchar(450)")
+                        .HasColumnOrder(2);
+
+                    b.HasKey("Id");
+
+                    b.HasIndex("AttachmentTypeId");
+
+                    b.HasIndex("ContractTaskId");
+
+                    b.ToTable("ContractTaskAttachment");
+                });
+
             modelBuilder.Entity("MTWorkHR.Core.Entities.CountryLookup", b =>
                 {
                     b.Property<long>("Id")
@@ -1833,6 +2131,120 @@ namespace MTWorkHR.Infrastructure.Migrations
                     b.ToTable("Projects");
                 });
 
+            modelBuilder.Entity("MTWorkHR.Core.Entities.ProjectStage", b =>
+                {
+                    b.Property<long>("Id")
+                        .ValueGeneratedOnAdd()
+                        .HasColumnType("bigint")
+                        .HasColumnOrder(0);
+
+                    SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<long>("Id"));
+
+                    b.Property<decimal?>("AmountPercent")
+                        .HasColumnType("decimal(18,2)");
+
+                    b.Property<long>("ContractId")
+                        .HasColumnType("bigint");
+
+                    b.Property<DateTime>("CreateDate")
+                        .HasColumnType("datetime2")
+                        .HasColumnOrder(3);
+
+                    b.Property<string>("CreateUser")
+                        .HasMaxLength(450)
+                        .HasColumnType("nvarchar(450)")
+                        .HasColumnOrder(1);
+
+                    b.Property<DateTime?>("ExpectedEndDate")
+                        .HasColumnType("datetime2");
+
+                    b.Property<string>("ScopeOfWork")
+                        .HasColumnType("nvarchar(max)");
+
+                    b.Property<DateTime?>("StartDate")
+                        .HasColumnType("datetime2");
+
+                    b.Property<string>("Title")
+                        .IsRequired()
+                        .HasMaxLength(250)
+                        .HasColumnType("nvarchar(250)");
+
+                    b.Property<DateTime?>("UpdateDate")
+                        .HasColumnType("datetime2")
+                        .HasColumnOrder(4);
+
+                    b.Property<string>("UpdateUser")
+                        .HasMaxLength(450)
+                        .HasColumnType("nvarchar(450)")
+                        .HasColumnOrder(2);
+
+                    b.HasKey("Id");
+
+                    b.HasIndex("ContractId");
+
+                    b.ToTable("ProjectStage");
+                });
+
+            modelBuilder.Entity("MTWorkHR.Core.Entities.ProjectStageAttachment", b =>
+                {
+                    b.Property<long>("Id")
+                        .ValueGeneratedOnAdd()
+                        .HasColumnType("bigint")
+                        .HasColumnOrder(0);
+
+                    SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<long>("Id"));
+
+                    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);
+
+                    b.Property<string>("CreateUser")
+                        .HasMaxLength(450)
+                        .HasColumnType("nvarchar(450)")
+                        .HasColumnOrder(1);
+
+                    b.Property<string>("FileName")
+                        .HasMaxLength(250)
+                        .HasColumnType("nvarchar(250)");
+
+                    b.Property<string>("FilePath")
+                        .HasColumnType("nvarchar(max)");
+
+                    b.Property<string>("OriginalName")
+                        .HasMaxLength(250)
+                        .HasColumnType("nvarchar(250)");
+
+                    b.Property<long>("ProjectStageId")
+                        .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("AttachmentTypeId");
+
+                    b.HasIndex("ProjectStageId");
+
+                    b.ToTable("ProjectStageAttachment");
+                });
+
             modelBuilder.Entity("MTWorkHR.Core.Entities.ProjectTeam", b =>
                 {
                     b.Property<long>("Id")
@@ -3316,6 +3728,45 @@ namespace MTWorkHR.Infrastructure.Migrations
                     b.Navigation("Country");
                 });
 
+            modelBuilder.Entity("MTWorkHR.Core.Entities.ContractAllowance", b =>
+                {
+                    b.HasOne("MTWorkHR.Core.Entities.Contract", "Contract")
+                        .WithMany("FixedAllowances")
+                        .HasForeignKey("ContractId")
+                        .OnDelete(DeleteBehavior.Cascade)
+                        .IsRequired();
+
+                    b.Navigation("Contract");
+                });
+
+            modelBuilder.Entity("MTWorkHR.Core.Entities.ContractTask", b =>
+                {
+                    b.HasOne("MTWorkHR.Core.Entities.Contract", "Contract")
+                        .WithMany("ContractTasks")
+                        .HasForeignKey("ContractId")
+                        .OnDelete(DeleteBehavior.Cascade)
+                        .IsRequired();
+
+                    b.Navigation("Contract");
+                });
+
+            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");
+                });
+
             modelBuilder.Entity("MTWorkHR.Core.Entities.MeetingUser", b =>
                 {
                     b.HasOne("MTWorkHR.Core.Entities.Meeting", "Meeting")
@@ -3344,6 +3795,34 @@ namespace MTWorkHR.Infrastructure.Migrations
                     b.Navigation("OrderType");
                 });
 
+            modelBuilder.Entity("MTWorkHR.Core.Entities.ProjectStage", b =>
+                {
+                    b.HasOne("MTWorkHR.Core.Entities.Contract", "Contract")
+                        .WithMany("ProjectStages")
+                        .HasForeignKey("ContractId")
+                        .OnDelete(DeleteBehavior.Cascade)
+                        .IsRequired();
+
+                    b.Navigation("Contract");
+                });
+
+            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");
+                });
+
             modelBuilder.Entity("MTWorkHR.Core.Entities.ProjectTeam", b =>
                 {
                     b.HasOne("MTWorkHR.Core.Entities.Project", "Project")
@@ -3605,6 +4084,20 @@ namespace MTWorkHR.Infrastructure.Migrations
                     b.Navigation("ChatAttachments");
                 });
 
+            modelBuilder.Entity("MTWorkHR.Core.Entities.Contract", b =>
+                {
+                    b.Navigation("ContractTasks");
+
+                    b.Navigation("FixedAllowances");
+
+                    b.Navigation("ProjectStages");
+                });
+
+            modelBuilder.Entity("MTWorkHR.Core.Entities.ContractTask", b =>
+                {
+                    b.Navigation("TaskAttachments");
+                });
+
             modelBuilder.Entity("MTWorkHR.Core.Entities.Meeting", b =>
                 {
                     b.Navigation("MeetingUsers");
@@ -3615,6 +4108,11 @@ namespace MTWorkHR.Infrastructure.Migrations
                     b.Navigation("ProjectTeams");
                 });
 
+            modelBuilder.Entity("MTWorkHR.Core.Entities.ProjectStage", b =>
+                {
+                    b.Navigation("StageAttachments");
+                });
+
             modelBuilder.Entity("MTWorkHR.Core.Entities.Team", b =>
                 {
                     b.Navigation("TeamUsers");

+ 8 - 0
MTWorkHR.Infrastructure/Repositories/Chat/ChatMessageRepository.cs

@@ -29,5 +29,13 @@ namespace MTWorkHR.Infrastructure.Repositories
 
             return new Tuple<IQueryable<ChatMessage>, int>(query, total);
         }
+
+        public async Task<Tuple<IQueryable<ChatMessage>, int>> GetAllUserMessagesAsync(string userId)
+        {
+            var query = dbSet.Include(x => x.ChatAttachments).Where(m => (m.SenderId == userId) || (m.ReceiverId == userId )).AsQueryable();
+            var total = await query.CountAsync();
+
+            return new Tuple<IQueryable<ChatMessage>, int>(query, total);
+        }
     }
 }

+ 37 - 0
MTWorkHR.Infrastructure/Repositories/Contract/ContractRepository.cs

@@ -0,0 +1,37 @@
+using Microsoft.EntityFrameworkCore;
+using MTWorkHR.Core.Entities;
+using MTWorkHR.Core.IDto;
+using MTWorkHR.Core.IRepositories;
+using MTWorkHR.Infrastructure.Entities;
+using MTWorkHR.Infrastructure.DBContext;
+
+namespace MTWorkHR.Infrastructure.Repositories
+{
+    public class ContractRepository : Repository<Contract>, IContractRepository
+    {
+        private readonly DbSet<Contract> dbSet;
+        public ContractRepository(HRDataContext context) : base(context)
+        {
+            dbSet = context.Set<Contract>();
+
+        }
+        public async Task<Contract> GetByIdWithAllChildren(long id)
+        {
+            return await dbSet
+                .Include(x => x.ContractTasks)
+                .Include(x => x.FixedAllowances)
+                .Include(x => x.ProjectStages)
+                .FirstOrDefaultAsync(x => x.Id == id);
+        }
+
+
+        public async Task<Tuple<IQueryable<Contract>, int>> GetAllWithChildrenAsync()
+        {
+            var query = dbSet//.Include(x => x.ContractUsers)
+                .AsQueryable();
+            var total = await query.CountAsync();
+
+            return new Tuple<IQueryable<Contract>, int>(query, total);
+        }
+    }
+}

+ 0 - 15
MTWorkHR.Infrastructure/Repositories/EmployeeRepository.cs

@@ -1,15 +0,0 @@
-using MTWorkHR.Core.Entities;
-using MTWorkHR.Core.IRepositories;
-
-using MTWorkHR.Infrastructure.DBContext;
-
-
-namespace MTWorkHR.Infrastructure.Repositories
-{
-    public class EmployeeRepository : Repository<Employee>, IEmployeeRepository
-    {
-        public EmployeeRepository(HRDataContext context) : base(context)
-        {
-        }
-    }
-}

+ 3 - 0
MTWorkHR.Infrastructure/UnitOfWork/UnitOfWork.cs

@@ -40,6 +40,7 @@ namespace MTWorkHR.Infrastructure.UnitOfWorks
         public ICityRepository City { get; }
         public IChatMessageRepository ChatMessage { get; }
         public IHubConnectionRepository HubConnection { get; }
+        public IContractRepository Contract{ get; }
 
         public UnitOfWork(HRDataContext _context
             , IPermissionRepository permission
@@ -67,6 +68,7 @@ namespace MTWorkHR.Infrastructure.UnitOfWorks
             , IMeetingUserRepository meetingUser
             , IProjectTeamRepository projectTeam
             , IChatMessageRepository chatMessage
+            , IContractRepository contract
             , IHubConnectionRepository connection
 
             )
@@ -97,6 +99,7 @@ namespace MTWorkHR.Infrastructure.UnitOfWorks
             MeetingUser = meetingUser;
             ProjectTeam = projectTeam;
             ChatMessage = chatMessage;
+            Contract = contract;
             HubConnection = connection;
         }