Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prueba Técnica Marcos Sánchez Hernández #2

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified .vs/slnx.sqlite
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
53 changes: 53 additions & 0 deletions PruebaTecnica/Controllers/MarketPartiesController.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
using Microsoft.AspNetCore.Mvc;
using PruebaTecnica.Servicio.Interfaz;

namespace PruebaTecnica.Controllers
{
[ApiController]
[Route("MarketPartiesController")]
public class MarketPartiesController : ControllerBase
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Añadir breves comentarios de lo que hace el controlador

{
private readonly ILogger<MarketPartiesController> _logger;
private readonly IBalanceResponsiblePartyService _balance;

public MarketPartiesController(ILogger<MarketPartiesController> logger, IBalanceResponsiblePartyService balance)
{
_logger = logger;
_balance = balance;
}


[HttpGet(Name = "ObtenerDatosApi")]
public IActionResult ObtenerDatosApi()
{
_logger.LogInformation("Entramos en el metodo");
var result = _balance.Save();
if (result.Data.CodigoResultado == 0)
{
return Ok("Datos guardados correctamente");
}
else
{
return NotFound();
}
}

[HttpGet(Name = "Data/{id}")]
public IActionResult GetDataById(int id)
{
_logger.LogInformation("Entramos en el método");

var result = _balance.ObtenerBalance(id);

if (result.Data.CodigoResultado == 0)
{
return Ok(result.Data);
}
else
{
return NotFound();
}

}
}
}
2 changes: 1 addition & 1 deletion PruebaTecnica/DTO/BalanceReponsiblePartiesDTO.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public class BalanceReponsiblePartiesDTO
[JsonProperty("BrpName")]
public string BrpName { get; set; }
[JsonProperty("BusinessId")]
public int BusinessId { get; set; }
public string BusinessId { get; set; }
[JsonProperty("CodingScheme")]
public string CodingScheme { get; set; }
[JsonProperty("Country")]
Expand Down
24 changes: 24 additions & 0 deletions PruebaTecnica/Genericos/ServiceResult.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
namespace PruebaTecnica.Genericos
{

public enum ResultType
{
Ok,NotFound,BadArguments
}
public class ServiceResult<T>
{
public ServiceResult()
{
Type=ResultType.Ok;
Errors=new List<string>();
Messages=new List<string>();
}

public T Data { get; set; }
public ResultType Type { get; set; }
public List<string>Errors { get; set; }
public List<string> Messages { get; set; }
}


}
4 changes: 2 additions & 2 deletions PruebaTecnica/Models/BalanceReponsiblePartiesModels.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public class BalanceReponsiblePartiesModels
[JsonProperty("CodigoResultado")]
public int CodigoResultado { get; set; }

[JsonProperty("Parties")]
public List<BalanceReponsiblePartiesDTO> Parties { get; set; }
[JsonProperty("BalanceResponsible")]
public BalanceReponsiblePartiesDTO BalanceResponsible { get; set; }
}
}
57 changes: 55 additions & 2 deletions PruebaTecnica/Servicio/BalanceResponsibleService.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,59 @@
namespace PruebaTecnica.Servicio
using PruebaTecnica.ContextoBBDD;
using PruebaTecnica.DTO;
using PruebaTecnica.Genericos;
using PruebaTecnica.Models;
using PruebaTecnica.Servicio.Interfaz;

namespace PruebaTecnica.Servicio
{
public class BalanceResponsibleService
public class BalanceResponsibleService : IBalanceResponsiblePartyService
{
private readonly ApplicationContext _context;

public BalanceResponsibleService(ApplicationContext context)
{
_context = context;
}

public ServiceResult<BalanceReponsiblePartiesModels> GetData(int id)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Añadir el patrón de comentarios sobre obtener la información de los datos o colocar una breve descripción de lo que hace el método,
Por lo general se escribe @id: y una breve descripción.

{
var result = new ServiceResult<BalanceReponsiblePartiesModels>();

var data = _context.BalanceResponsibles.FirstOrDefault(x => x.Id == id);

if (data == null)
{
result.Data = new BalanceReponsiblePartiesModels()
{
CodigoResultado = 1,
BalanceResponsible = null
};
return result;
}

var dataDto = new BalanceReponsiblePartiesDTO
{
BrpCode=data.BrpCode,
BrpName=data.BrpName,
BusinessId=data.BusinessId,
CodingScheme=data.CodingScheme,
Country=data.Country,
ValidityEnd= data.ValidityEnd,
ValidityStart= data.ValidityStart
};

result.Data = new BalanceReponsiblePartiesModels()
{
CodigoResultado = 0,
BalanceResponsible = dataDto
};

return result;
}

public ServiceResult<BalanceReponsiblePartiesModels> Save()
{
throw new NotImplementedException();
}
}
}
11 changes: 11 additions & 0 deletions PruebaTecnica/Servicio/Interfaz/IBalanceResponsiblePartyService.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using PruebaTecnica.Genericos;
using PruebaTecnica.Models;

namespace PruebaTecnica.Servicio.Interfaz
{
public interface IBalanceResponsiblePartyService
{
ServiceResult<BalanceReponsiblePartiesModels> Save();
ServiceResult<BalanceReponsiblePartiesModels> GetData(int id);
}
}
6 changes: 0 additions & 6 deletions PruebaTecnica/Servicio/Interfaz/IBalanceResponsibleService.cs

This file was deleted.