zinab_elgendy 1 тиждень тому
батько
коміт
3465d7649d

+ 1 - 3
MTWorkHR.API/Controllers/ContractController.cs

@@ -3,10 +3,8 @@
 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
 {
@@ -23,7 +21,7 @@ namespace MTWorkHR.API.Controllers
         [HttpGet("GetAll")]
         [ProducesResponseType(StatusCodes.Status200OK)]
 
-        public async Task<ActionResult<List<ContractDto>>> GetAll([FromQuery] PagingInputDto pagingInput)
+        public async Task<ActionResult<List<ContractDto>>> GetAll([FromQuery] ContractPagingInputDto pagingInput)
         {
             return Ok(await _ContractService.GetAll(pagingInput));
         }

+ 20 - 15
MTWorkHR.API/Program.cs

@@ -38,7 +38,7 @@ var config = new AppSettingsConfiguration();
 // Add services to the container.
 builder.Services.AddDbContext<HRDataContext>(options =>
 {
-    options.UseSqlServer(config.ConnectionStrings.LocalConnectionString);
+    options.UseSqlServer(config.ConnectionStrings.mt);
     //  options.UseSqlServer(builder.Configuration.GetSection("ConnectionStrings:MTWorkHRConnectionString").Value);
 });
 
@@ -106,6 +106,11 @@ builder.Services.ConfigureReportingServices(configurator => {
 builder.Services.AddEndpointsApiExplorer();
 //builder.Services.AddSwaggerGen();
 //--------------------------
+builder.Services.AddSignalR(options =>
+{
+    options.EnableDetailedErrors = true;
+});
+
 builder.Services.AddSwaggerGen(swagger =>
 {
     //This is to apply global headers for all requests
@@ -152,10 +157,7 @@ builder.Services.AddSwaggerGen(swagger =>
                     }
                 });
 });
-builder.Services.AddSignalR(options =>
-{
-    options.EnableDetailedErrors = true;
-});
+
 //--------------------------
 var app = builder.Build();
 
@@ -168,7 +170,11 @@ app.UseSwagger();
 app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "MTWorkHR.API v1"));
 // }
 
+
+app.UseRouting();  // <-- Add UseRouting() here
+
 app.UseCors(x => x
+    .WithOrigins("https://api.mtwork.com", "https://mtworkhrclient.azurewebsites.net", "http://localhost:4200/") // Allowed origin
     .AllowAnyMethod()
     .AllowAnyHeader()
     .SetIsOriginAllowed(origin =>
@@ -176,21 +182,20 @@ app.UseCors(x => x
     .AllowCredentials()); // allow credentials
 
 
-//app.MapPost("broadcast", async (string message, IHubContext<ChatHub, IChatClient> context) =>
-//{
-//    await context.Clients.All.ReceiveMessage(message);
-//    return Results.NoContent();
-//});
 
-//app.UseEndpoints(endpoints =>
-//{
-//    endpoints.MapHub<ChatHub>("/chatHub");
-//});
+
+
+
+
 app.UseHttpsRedirection();
 app.UseAuthentication();
 app.UseAuthorization();
+app.UseEndpoints(endpoints =>
+{
+    endpoints.MapHub<ChatHub>("/chatHub"); // Map your SignalR hub
+});
 app.UseMiddleware<LoggingMiddleware>();
 app.MapControllers();
-app.MapHub<ChatHub>("/chatHub");
+//app.MapHub<ChatHub>("/chatHub");
 
 app.Run();

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

@@ -14,6 +14,7 @@ namespace MTWorkHR.Application.Models
     public class ContractDto : EntityDto
     {
         public ContractTypeEnum ContractTypeId { get; set; }
+        public ContractStatusEnum ContractStatusId { get; set; }
 
         public long CompanyId { get; set; }
         public string CompanyRepresentativeId { get; set; }

+ 17 - 0
MTWorkHR.Application/Dtos/Contract/ContractPagingInputDto.cs

@@ -0,0 +1,17 @@
+using MTWorkHR.Core.IDto;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace MTWorkHR.Application.Models
+{
+    public class ContractPagingInputDto : PagingInputDto, IContractPagingInputDto
+    {
+        public long? ContractStatusId { get; set; }
+        public long? ContractTypeId { get; set; }
+
+
+    }
+}

+ 10 - 1
MTWorkHR.Application/Services/Contract/ContractService.cs

@@ -62,7 +62,7 @@ namespace MTWorkHR.Application.Services
         //    var response = Mapper.MapperObject.Mapper.Map<ContractDto>(entity);
         //    return response;
         //}
-        public override async Task<PagingResultDto<ContractDto>> GetAll(PagingInputDto PagingInputDto)
+        public async Task<PagingResultDto<ContractDto>> GetAll(ContractPagingInputDto PagingInputDto)
         {
             var res = await _unitOfWork.Contract.GetAllWithChildrenAsync();
             var query = res.Item1;
@@ -78,6 +78,15 @@ namespace MTWorkHR.Application.Services
                 query = query.Where(u => u.JobDescription.Contains(filter));
             }
 
+            if (PagingInputDto.ContractStatusId != null)
+            {
+                query = query.Where(u => (int)u.ContractStatusId == PagingInputDto.ContractStatusId);
+            }
+            if (PagingInputDto.ContractTypeId != null)
+            {
+                query = query.Where(u => (int)u.ContractTypeId == PagingInputDto.ContractTypeId);
+            }
+
             var order = query.OrderBy(PagingInputDto.OrderByField + " " + PagingInputDto.OrderType);
 
             var page = order.Skip((PagingInputDto.PageNumber * PagingInputDto.PageSize) - PagingInputDto.PageSize).Take(PagingInputDto.PageSize);

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

@@ -7,5 +7,7 @@ namespace MTWorkHR.Application.Services.Interfaces
 {
     public interface IContractService : IService<Contract, ContractDto, ContractDto>
     {
+        Task<PagingResultDto<ContractDto>> GetAll(ContractPagingInputDto PagingInputDto);
+
     }
 }

+ 11 - 0
MTWorkHR.Core/IDto/IContractPagingInputDto.cs

@@ -0,0 +1,11 @@
+using System.Collections.Generic;
+
+namespace MTWorkHR.Core.IDto
+{
+    public interface IContractPagingInputDto : IPagingInputDto
+    {
+        public long? ContractStatusId { get; set; }
+        public long? ContractTypeId { get; set; }
+
+    }
+}