diff --git a/AdminusaBackend/Contracts/Reportes/IRpRepository.cs b/AdminusaBackend/Contracts/Reportes/IRpRepository.cs index a06e9bc..fc0ea37 100644 --- a/AdminusaBackend/Contracts/Reportes/IRpRepository.cs +++ b/AdminusaBackend/Contracts/Reportes/IRpRepository.cs @@ -1,4 +1,5 @@ -using AdminusaBackend.DTO.Reportes; +using AdminusaBackend.DTO; +using AdminusaBackend.DTO.Reportes; using AdminusaBackend.Models.Reportes; namespace AdminusaBackend.Contracts.Reportes @@ -15,5 +16,10 @@ namespace AdminusaBackend.Contracts.Reportes public Task> GetNoRelaciones(); public Task> GetTotalHoursWorkings(string Inicio, string Fin ); + + + + public Task>PostTotalHours(WorkingHours data); + } } diff --git a/AdminusaBackend/Controllers/Reportes/ReportesController.cs b/AdminusaBackend/Controllers/Reportes/ReportesController.cs index 29862dd..7879691 100644 --- a/AdminusaBackend/Controllers/Reportes/ReportesController.cs +++ b/AdminusaBackend/Controllers/Reportes/ReportesController.cs @@ -1,5 +1,7 @@ -using AdminusaBackend.Contracts.Catalogos; +using System.Numerics; +using AdminusaBackend.Contracts.Catalogos; using AdminusaBackend.Contracts.Reportes; +using AdminusaBackend.DTO; using AdminusaBackend.DTO.Reportes; using AdminusaBackend.Models.Reportes; using Microsoft.AspNetCore.Mvc; @@ -9,15 +11,15 @@ namespace AdminusaBackend.Controllers.Reportes { [Route("api/[controller]")] - + public class ReportesController : Controller { public IConfiguration _Configuration; - private readonly IRptRepository _Repo; - - + private readonly IRptRepository _Repo; + + public ReportesController(IConfiguration config, IRptRepository Repo) { _Configuration = config; @@ -37,7 +39,7 @@ namespace AdminusaBackend.Controllers.Reportes [Route("GetAllNoRelaciones")] [HttpGet] - public async Task> GetNoRelaciones() + public async Task> GetNoRelaciones() { var result = await _Repo.GetNoRelaciones(); return result; @@ -48,7 +50,7 @@ namespace AdminusaBackend.Controllers.Reportes public async Task> GetWorkingHours(string Inicio, string Fin) { - var result = await _Repo.GetWorkingHours(Inicio, Fin); + var result = await _Repo.GetWorkingHours(Inicio, Fin); return result; } @@ -62,6 +64,13 @@ namespace AdminusaBackend.Controllers.Reportes return result; } + [Route("UpdateWorkingHours")] + [HttpPost] + public async Task> UpdateWorkingHours([FromBody] WorkingHours data) + { + var result = await _Repo.PostTotalHours(data); + return result; + } diff --git a/AdminusaBackend/DTO/DTOClocks.cs b/AdminusaBackend/DTO/DTOClocks.cs new file mode 100644 index 0000000..be8cc24 --- /dev/null +++ b/AdminusaBackend/DTO/DTOClocks.cs @@ -0,0 +1,18 @@ +namespace AdminusaBackend.DTO +{ + public class DTOClocks + { + public string? EmpNo { get; set; } + public string? Date { get; set; } + public string? ClockIn1 { get; set; } + public string? ClockOut1 { get; set; } + public string? ClockIn2 { get; set; } + public string? ClockOut2 { get; set; } + public string? ClockIn3 { get; set; } + public string? ClockOut3 { get; set; } + public string? ClockIn4 { get; set; } + public string? ClockOut4 { get; set; } + public string? ClockIn5 { get; set; } + public string? ClockOut5 { get; set; } + } +} diff --git a/AdminusaBackend/Program.cs b/AdminusaBackend/Program.cs index 4a0112a..e43d08c 100644 --- a/AdminusaBackend/Program.cs +++ b/AdminusaBackend/Program.cs @@ -51,19 +51,7 @@ internal class Program builder.Services.AddControllers(); - /* builder.Services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme).AddJwtBearer(options => - { - options.RequireHttpsMetadata = false; - options.SaveToken = true; - options.TokenValidationParameters = new TokenValidationParameters() - { - ValidateIssuer = true, - ValidateAudience = true, - ValidAudience = builder.Configuration["Jwt:Audience"], - ValidIssuer = builder.Configuration["Jwt:Issuer"], - IssuerSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(builder.Configuration["Jwt:Key"])) - }; - });*/ + builder.Services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme) diff --git a/AdminusaBackend/Repository/Reportes/ReportesRepository.cs b/AdminusaBackend/Repository/Reportes/ReportesRepository.cs index 68af600..17e5e28 100644 --- a/AdminusaBackend/Repository/Reportes/ReportesRepository.cs +++ b/AdminusaBackend/Repository/Reportes/ReportesRepository.cs @@ -1,5 +1,6 @@ using AdminusaBackend.Context; using AdminusaBackend.Contracts.Reportes; +using AdminusaBackend.DTO; using AdminusaBackend.DTO.Reportes; using AdminusaBackend.Models.Reportes; using Dapper; @@ -72,6 +73,33 @@ namespace AdminusaBackend.Repository.Reportes + public async Task>PostTotalHours(WorkingHours data) + { + + + var query = "[UpdateTotalTiempos]"; + using var con = _context.CreateConnection(); + var result = await con.QueryAsync(query, new + { + data.EmpNo, + data.Date, + data.ClockIn1, + data.ClockOut1, + data.ClockIn2, + data.ClockOut2, + data.ClockIn3, + data.ClockOut3, + data.ClockIn4, + data.ClockOut4, + data.ClockIn5, + data.ClockOut5 + + }, commandType: CommandType.StoredProcedure); + return result.ToList(); + } + + +