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

Conversation

zikram013
Copy link

Creación de una api de swagger para traer los datos según el filtro de que se introduzca simulando al de la Api dada a la cual llama.
Se implementa una arquitectura DDD para controlador y servicios necesarios.
Se implementa una arquitectura repository para guardar y traer los objetos desde la BBDD, se implementan tambien mapeos de DTO a entidad y viceversa para la gestión de los datos.
Se hace uso de Linq.
Implementación de errores según se encuentren datos o no se pueda realizar la petición

Copy link
Owner

@calujord calujord left a comment

Choose a reason for hiding this comment

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

  1. Gestión correcta del repositorio
  2. La data transformation lo realiza de forma correcta con cosas que podrían mejorarse
  3. La conexión con el web service no gestiona las excepciones o si se llega a caer el servicio.
  4. Sería bueno que esten comentadas todas las funciones métodos y atributos, de esta forma puede haber mejor seguimiento de código.


namespace PruebaTecnica.Repository
{
public class BalanceResponsiblePartyRepository : Repository<BalanceResponsibleParty>, IBalanceResponsiblePartyRepository
Copy link
Owner

Choose a reason for hiding this comment

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

Comentarios sobre lo que hace la clase

_webApiExterna = webApiExterna;
_balanceResponsiblePartyServiceRepository = balanceResponsiblePartyServiceRepository;
}

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.

}

public ServiceResult<BalanceReponsiblePartiesModels> GetData(int id)
{
var result = new ServiceResult<BalanceReponsiblePartiesModels>();

var data = _context.BalanceResponsibles.FirstOrDefault(x => x.Id == id);
var data = _balanceResponsiblePartyServiceRepository.Get(id);
Copy link
Owner

Choose a reason for hiding this comment

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

Como recomendación añadir el tipo de dato que devuelve la respuesta

{
public class BalanceReponsiblePartiesDTO
{
[JsonProperty("BrpCode")]
Copy link
Owner

Choose a reason for hiding this comment

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

Se valorará mucho los comentarios de cada una de las propiedades para poder entender mejor los datos que se están transformando

{
[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

{
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)] // Esta anotación hace que el ID sea autoincremental
public int Id { get; set; }
Copy link
Owner

Choose a reason for hiding this comment

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

Siempre es positivo añadir la una breve descripción de las propiedades de lo que se va a obtener de esta forma mejorará la lectura del código

{
var result = new ServiceResult<BalanceReponsiblePartiesModels>();
var datosApi = _webApiExterna.TraerDatosApi(code, country, name);
if (datosApi.CodigoResultado == 1)
Copy link
Owner

Choose a reason for hiding this comment

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

Validación de http error, o si lanza alguna excepción como error 500 o 404


result.Data = new BalanceReponsiblePartiesModels()
{
CodigoResultado = 0,
Copy link
Owner

Choose a reason for hiding this comment

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

Por lo general cuando se gestiona los errores se maneja las excepciones

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants