zinab_elgendy hai 10 meses
pai
achega
9424bacbde

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

@@ -28,9 +28,9 @@ namespace MTWorkHR.API.Controllers
         [HttpGet("Get")]
         [ProducesResponseType(StatusCodes.Status200OK)]
 
-        public async Task<ActionResult<OrderRequestDto>> Get(long LeaveRequestId)
+        public async Task<ActionResult<OrderRequestDto>> Get(long OrderRequestId)
         {
-            return Ok(await _LeaveRequestService.GetById(LeaveRequestId));
+            return Ok(await _LeaveRequestService.GetById(OrderRequestId));
         }
 
 

MTWorkHR.Application/Dtos/Identity/CompanyDto.cs → MTWorkHR.Application/Dtos/User/CompanyDto.cs


+ 2 - 2
MTWorkHR.Application/Services/EmployeeService.cs

@@ -11,12 +11,12 @@ using System.Threading.Tasks;
 
 namespace MTWorkHR.Application.Services
 {
-    public class CompanyService
+    public class EmployeeService
     {
         private readonly ICompanyRepository _companyRepository;
         private readonly IMapper _mapper;
         private readonly IAppLogger<UserDto> _logger;
-        public CompanyService(ICompanyRepository companyRepository, IMapper mapper, IAppLogger<UserDto> logger) 
+        public EmployeeService(ICompanyRepository companyRepository, IMapper mapper, IAppLogger<UserDto> logger) 
         {
             _companyRepository = companyRepository;
             _mapper = mapper;

MTWorkHR.Application/Identity/IAuthService.cs → MTWorkHR.Application/Services/Interfaces/IAuthService.cs


+ 2 - 1
MTWorkHR.Application/Identity/IUserService.cs

@@ -18,12 +18,13 @@ namespace MTWorkHR.Application.Identity
         Task Delete(string id);
         Task<UserDto> Create(UserDto input);
         Task<UserDto> Update(UserDto input);
-        Task<UserDto> UpdateWithoutChildren(UserDto input);
         Task ForgetPasswordMail(string input);
         Task<bool> ResetPassword(ResetPasswordDto input);
 
         Task<bool> ForgetPassword(ForgetPasswordDto model);
         Task<bool> ConfirmEmail(ForgetPasswordDto model);
         Task<bool> IsExpiredToken(ForgetPasswordDto model);
+
+       
     }
 }

+ 2 - 1
MTWorkHR.Application/Services/User/OrderAllocationService.cs

@@ -45,12 +45,13 @@ namespace MTWorkHR.Application.Services
             var allocations = new List<OrderAllocation>();
             foreach (var emp in employees)
             {
-                if (await _unitOfWork.OrderAllocation.AllocationExists(emp.Id, orderType.Id, period))
+                if (await _unitOfWork.OrderAllocation.AllocationExists(emp.Id, orderType.Id, input.LeaveTypeId, period))
                     continue;
                 allocations.Add(new OrderAllocation
                 {
                     EmployeeId = emp.Id,
                     OrderTypeId = orderType.Id,
+                    LeaveTypeId = leaveType != null ? leaveType.Id : null,
                     NumberOfDays = leaveType != null ? leaveType.DefaultDays : orderType.DefaultDays,
                     Period = period
                 });

+ 3 - 3
MTWorkHR.Application/Services/User/OrderRequestService.cs

@@ -36,14 +36,14 @@ namespace MTWorkHR.Application.Services
 
         public override async Task<OrderRequestDto> GetById(long id)
         {
-            var entity = await _unitOfWork.OrderRequest.GetByIdAsync(id);
+            var entity = await _unitOfWork.OrderRequest.GetByIdWithAllChildren(id);
             var response = MapperObject.Mapper.Map<OrderRequestDto>(entity);
             return response;
         }
         public override async Task<OrderRequestDto> Create(OrderRequestDto input)
         {
             var period = DateTime.Now.Year;
-            var allocation = await _unitOfWork.OrderAllocation.GetUserAllocations(input.RequestingEmployeeId, input.OrderTypeId, input.LeaveTypeId.HasValue?input.LeaveTypeId.Value:0, period);
+            var allocation = await _unitOfWork.OrderAllocation.GetUserAllocations(input.RequestingEmployeeId, input.OrderTypeId, input.LeaveTypeId, period);
 
             if (allocation is null)
             {
@@ -93,7 +93,7 @@ namespace MTWorkHR.Application.Services
             orderRequest.OrderStatus = (ApprovalStatusEnum)statusId;
             if (orderRequest.OrderStatus == ApprovalStatusEnum.Approved)
             {
-                var allocation = await _unitOfWork.OrderAllocation.GetUserAllocations(orderRequest.RequestingEmployeeId, orderRequest.OrderTypeId, orderRequest.LeaveTypeId.HasValue ? orderRequest.LeaveTypeId.Value : 0, DateTime.Now.Year);
+                var allocation = await _unitOfWork.OrderAllocation.GetUserAllocations(orderRequest.RequestingEmployeeId, orderRequest.OrderTypeId, orderRequest.LeaveTypeId, DateTime.Now.Year);
                 int daysRequested = !orderRequest.EndDate.HasValue ? 1 : (int)(orderRequest.EndDate.Value - orderRequest.StartDate).TotalDays;
                 allocation.NumberOfDays -= daysRequested;
             }

+ 2 - 0
MTWorkHR.Core/Entities/Attendance/Attendance.cs

@@ -12,7 +12,9 @@ namespace MTWorkHR.Core.Entities
     public class Attendance : FullAuditEntity
     {
         [Required]
+        [Filter]
         public string UserId { get; set; }
+        [Filter]
         public string? UserName { get; set; }
         public DateTime? CheckInTime { get; set; }
         public DateTime? CheckOutTime { get; set; }

+ 1 - 1
MTWorkHR.Core/Entities/Attendance/OrderAllocation.cs

@@ -19,8 +19,8 @@ namespace MTWorkHR.Core.Entities
         [ForeignKey("LeaveTypeId")]
         public LeaveType? LeaveType { get; set; }
         public long? LeaveTypeId { get; set; }
-
         public int Period { get; set; }
+        [Filter]
         public string EmployeeId { get; set; }
 
     }

+ 1 - 0
MTWorkHR.Core/Entities/Attendance/OrderRequest.cs

@@ -24,6 +24,7 @@ namespace MTWorkHR.Core.Entities.User
 
         public string? RequestComments { get; set; }
         public ApprovalStatusEnum? OrderStatus { get; set; }
+        [Filter]
         public string RequestingEmployeeId { get; set; }
         public int? CountryId{ get; set; }
         public int? CityId { get; set; }

+ 2 - 2
MTWorkHR.Core/Entities/Auth/Company.cs

@@ -11,9 +11,9 @@ namespace MTWorkHR.Core.Entities
     public class Company : FullAuditEntity
     {
         public long UserId { get; set; }
-
+        [Filter]
         public string CompanyName { get; set; }
-
+        [Filter]
         public string CRNumber { get; set; }
         public int TaxNumber { get; set; }
     }

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

@@ -21,6 +21,7 @@ namespace MTWorkHR.Core.Entities
         public DateTime StartDate { get; set; }
         public DateTime EndDate { get; set; }
         [MaxLength(250)]
+        [Filter]
         public string? Location { get; set; }
         [MaxLength(250)]
         public string? MeetingLink { get; set; }

+ 2 - 2
MTWorkHR.Core/Entities/User/UserTask.cs

@@ -12,9 +12,9 @@ namespace MTWorkHR.Core.Entities
     public class UserTask : FullAuditEntity
     {
         public long AssignedUserId { get; set; }
-
+        [Filter]
         public string Title { get; set; }
-        
+        [Filter]
         public string Description { get; set; }
         public DateTime DueDate { get; set; }
         public PriorityEnum Priority { get; set; }

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

@@ -14,6 +14,7 @@ namespace MTWorkHR.Core.Entities
     {
         public long AssignedToUserId { get; set; }
         [MaxLength(500)]
+        [Filter]
         public string? Comment { get; set; }
         public long TaskId { get; set; }
 

+ 2 - 2
MTWorkHR.Core/IRepositories/User/IOrderAllocationRepository.cs

@@ -10,9 +10,9 @@ namespace MTWorkHR.Core.IRepositories
 {
     public interface IOrderAllocationRepository : IRepository<OrderAllocation>
     {
-        Task<bool> AllocationExists(string userId, long orderTypeId, int period);
+        Task<bool> AllocationExists(string userId, long orderTypeId, long? leaveTypeId, int period);
         Task<OrderAllocation> GetByIdWithAllChildren(long id);
-        Task<OrderAllocation> GetUserAllocations(string userId, long orderTypeId, long leaveTypeId, int period);
+        Task<OrderAllocation> GetUserAllocations(string userId, long orderTypeId, long? leaveTypeId, int period);
 
     }
 }

+ 1 - 0
MTWorkHR.Core/IRepositories/User/IOrderRequestRepository.cs

@@ -11,6 +11,7 @@ namespace MTWorkHR.Core.IRepositories
 {
     public interface IOrderRequestRepository : IRepository<OrderRequest>
     {
+       Task<OrderRequest> GetByIdWithAllChildren(long id);
 
     }
 }

+ 6 - 5
MTWorkHR.Infrastructure/Repositories/User/OrderAllocationRepository.cs

@@ -25,19 +25,20 @@ namespace MTWorkHR.Infrastructure.Repositories
 
      
 
-        public async Task<bool> AllocationExists(string userId, long orderTypeId, int period)
+        public async Task<bool> AllocationExists(string userId, long orderTypeId, long? leaveTypeId, int period)
         {
             return await dbSet.AnyAsync(q => q.EmployeeId == userId
                                         && q.OrderTypeId == orderTypeId
-                                        && q.Period == period);
+                                        && q.Period == period
+                                        && (!leaveTypeId.HasValue || leaveTypeId == 0 || leaveTypeId == q.LeaveTypeId));
         }
 
-        public async Task<OrderAllocation> GetUserAllocations(string userId, long orderTypeId, long leaveTypeId, int period)
+        public async Task<OrderAllocation> GetUserAllocations(string userId, long orderTypeId, long? leaveTypeId, int period)
         {
             return await dbSet.FirstOrDefaultAsync(q => q.EmployeeId == userId
                                         && q.OrderTypeId == orderTypeId
-                                          && q.Period == period
-                                          && (leaveTypeId == 0 || leaveTypeId == q.LeaveTypeId));
+                                        && q.Period == period
+                                        && (!leaveTypeId.HasValue || leaveTypeId == 0 || leaveTypeId == q.LeaveTypeId));
         }
     }
 }