Update TaxCondition Endpoint in API
All checks were successful
CI/CD Pipeline / Build and Deploy with Docker Compose (push) Successful in 5m18s
All checks were successful
CI/CD Pipeline / Build and Deploy with Docker Compose (push) Successful in 5m18s
This commit is contained in:
parent
0da0d7c829
commit
42e67d5600
15
Core/Interfaces/ITaxConditionDom.cs
Normal file
15
Core/Interfaces/ITaxConditionDom.cs
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
using Domain.Entities;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Core.Interfaces
|
||||||
|
{
|
||||||
|
public interface ITaxConditionDom
|
||||||
|
{
|
||||||
|
Task<IEnumerable<ETaxCondition>> GetAllAsync();
|
||||||
|
Task<ETaxCondition?> GetByNameAsync(string name);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -23,7 +23,6 @@ namespace Core.Interfaces
|
|||||||
Task<IEnumerable<ETickets_GetSummary>> GetSummaryAsync(); // Cambiado a asincrónico
|
Task<IEnumerable<ETickets_GetSummary>> GetSummaryAsync(); // Cambiado a asincrónico
|
||||||
Task<IEnumerable<ETicket_Dashboard>> GetTicketDashboardAsync(string estado, string orden); // Cambiado a asincrónico
|
Task<IEnumerable<ETicket_Dashboard>> GetTicketDashboardAsync(string estado, string orden); // Cambiado a asincrónico
|
||||||
Task InsertTicketAsync(ETicket ticket); // Cambiado a asincrónico
|
Task InsertTicketAsync(ETicket ticket); // Cambiado a asincrónico
|
||||||
|
|
||||||
Task<byte[]> ExcelTicketDashboardAsync(string estado, string orden);
|
Task<byte[]> ExcelTicketDashboardAsync(string estado, string orden);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -7,13 +7,14 @@ namespace Core.Services
|
|||||||
{
|
{
|
||||||
public class AccountTypeService : IAccountTypeDom
|
public class AccountTypeService : IAccountTypeDom
|
||||||
{
|
{
|
||||||
|
#region Declaraciones y Constructor
|
||||||
private readonly IPhSAccountTypeRepository _repository;
|
private readonly IPhSAccountTypeRepository _repository;
|
||||||
|
|
||||||
public AccountTypeService(IPhSAccountTypeRepository repository)
|
public AccountTypeService(IPhSAccountTypeRepository repository)
|
||||||
{
|
{
|
||||||
_repository = repository ?? throw new ArgumentNullException(nameof(repository));
|
_repository = repository ?? throw new ArgumentNullException(nameof(repository));
|
||||||
}
|
}
|
||||||
|
#endregion
|
||||||
|
#region Metodos de clase
|
||||||
public async Task<IEnumerable<EAccountType>> GetAllAsync()
|
public async Task<IEnumerable<EAccountType>> GetAllAsync()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@ -26,7 +27,6 @@ namespace Core.Services
|
|||||||
throw new Exception($"{methodName} Message: {ex.Message}", ex);
|
throw new Exception($"{methodName} Message: {ex.Message}", ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<EAccountType?> GetByNameAsync(string name)
|
public async Task<EAccountType?> GetByNameAsync(string name)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@ -39,5 +39,6 @@ namespace Core.Services
|
|||||||
throw new Exception($"{methodName} Message: {ex.Message}", ex);
|
throw new Exception($"{methodName} Message: {ex.Message}", ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
44
Core/Services/TaxConditionService.cs
Normal file
44
Core/Services/TaxConditionService.cs
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
using Core.Interfaces;
|
||||||
|
using Domain.Entities;
|
||||||
|
using Models.Interfaces;
|
||||||
|
using System.Reflection;
|
||||||
|
|
||||||
|
namespace Core.Services
|
||||||
|
{
|
||||||
|
public class TaxConditionService : ITaxConditionDom
|
||||||
|
{
|
||||||
|
#region Declaraciones y Constructor
|
||||||
|
private readonly IPhSTaxConditionRepository _repository;
|
||||||
|
public TaxConditionService(IPhSTaxConditionRepository repository)
|
||||||
|
{
|
||||||
|
_repository = repository ?? throw new ArgumentNullException(nameof(repository));
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
#region Metodos de clase
|
||||||
|
public async Task<IEnumerable<ETaxCondition>> GetAllAsync()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return await _repository.GetAllAsync();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
var methodName = MethodBase.GetCurrentMethod()?.Name ?? "UnknownMethod";
|
||||||
|
throw new Exception($"{methodName} Message: {ex.Message}", ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public async Task<ETaxCondition?> GetByNameAsync(string name)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return await _repository.GetByNameAsync(name);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
var methodName = MethodBase.GetCurrentMethod()?.Name ?? "UnknownMethod";
|
||||||
|
throw new Exception($"{methodName} Message: {ex.Message}", ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
||||||
11
Domain/Entities/ETaxCondition.cs
Normal file
11
Domain/Entities/ETaxCondition.cs
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
namespace Domain.Entities
|
||||||
|
{
|
||||||
|
public class ETaxCondition
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
|
||||||
|
public string Description { get; set; } = null!;
|
||||||
|
|
||||||
|
public string CmpClase { get; set; } = null!;
|
||||||
|
}
|
||||||
|
}
|
||||||
10
Models/Interfaces/IPhSTaxConditionRepository.cs
Normal file
10
Models/Interfaces/IPhSTaxConditionRepository.cs
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
using Domain.Entities;
|
||||||
|
|
||||||
|
namespace Models.Interfaces
|
||||||
|
{
|
||||||
|
public interface IPhSTaxConditionRepository
|
||||||
|
{
|
||||||
|
Task<IEnumerable<ETaxCondition>> GetAllAsync();
|
||||||
|
Task<ETaxCondition?> GetByNameAsync(string name);
|
||||||
|
}
|
||||||
|
}
|
||||||
27
Models/Repositories/PhOhTaxConditionRepository.cs
Normal file
27
Models/Repositories/PhOhTaxConditionRepository.cs
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
using Domain.Entities;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Models.Helpers;
|
||||||
|
using Models.Interfaces;
|
||||||
|
using Models.Models;
|
||||||
|
|
||||||
|
namespace Models.Repositories
|
||||||
|
{
|
||||||
|
public class PhOhTaxConditionRepository(PhronCareOperationsHubContext context): IPhSTaxConditionRepository
|
||||||
|
{
|
||||||
|
#region Declaraciones y Constructor
|
||||||
|
private readonly PhronCareOperationsHubContext _context = context;
|
||||||
|
#endregion
|
||||||
|
#region Metodos de clase
|
||||||
|
async Task<IEnumerable<ETaxCondition>> IPhSTaxConditionRepository.GetAllAsync()
|
||||||
|
{
|
||||||
|
var accountTypes = await _context.PhOhTaxConditions.ToListAsync();
|
||||||
|
return accountTypes.Select(EntityMapper.MapEntity<PhOhTaxCondition, ETaxCondition>);
|
||||||
|
}
|
||||||
|
public async Task<ETaxCondition?> GetByNameAsync(string name)
|
||||||
|
{
|
||||||
|
var taxDescription = await _context.PhOhTaxConditions.FirstOrDefaultAsync(a => a.Description.Contains(name));
|
||||||
|
return taxDescription != null ? EntityMapper.MapEntity<PhOhTaxCondition, ETaxCondition>(taxDescription) : null;
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
||||||
40
phronCare.API/Controllers/Sales/TaxConditionController.cs
Normal file
40
phronCare.API/Controllers/Sales/TaxConditionController.cs
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
using Core.Interfaces;
|
||||||
|
using Microsoft.AspNetCore.Http;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
|
||||||
|
namespace phronCare.API.Controllers.Sales
|
||||||
|
{
|
||||||
|
[Route("api/[controller]")]
|
||||||
|
[ApiController]
|
||||||
|
public class TaxConditionController : ControllerBase
|
||||||
|
{
|
||||||
|
private readonly ITaxConditionDom _taxConditionService ;
|
||||||
|
public TaxConditionController(ITaxConditionDom taxConditionService)
|
||||||
|
{
|
||||||
|
_taxConditionService = taxConditionService ?? throw new ArgumentNullException(nameof(taxConditionService));
|
||||||
|
}
|
||||||
|
[HttpGet("GetAll")]
|
||||||
|
public async Task<IActionResult> GetAll()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var result = await _taxConditionService.GetAllAsync();
|
||||||
|
return Ok(result);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
return BadRequest(ex.Message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
[HttpGet("GetByName/{name}")]
|
||||||
|
public async Task<IActionResult> GetByName(string name)
|
||||||
|
{
|
||||||
|
var result = await _taxConditionService.GetByNameAsync(name);
|
||||||
|
if (result == null)
|
||||||
|
return NotFound($"No se encontró un tipo de cuenta con el nombre '{name}'.");
|
||||||
|
|
||||||
|
return Ok(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user