app.MapPost( "create-income-register", [Authorize] async ( CancellationToken token, [FromBody] CreateIncomeRegisterRequest request, [FromServices] IRegisterService registerService ) => { if (!RegisterType.CheckIfIsValidType(request.Type, out bool isTransfer)) { throw new InvalidRegisterTypeException(); } if(!RegisterRepetitionType.CheckIfIsValidType(request.RepetitionType)) { throw new InvalidRegisterRepetitionTypeException(); } if(!Periodicities.CheckIfIsValidType(request.Periodicity)) { throw new InvalidPeriodicityException(); } await registerService.CreateIncomeRegister(request, token); return Results.Ok(); } ); app.MapPost( "create-outcome-register", [Authorize] async ( CancellationToken token, [FromBody] CreateOutcomeRegisterRequest request, [FromServices] IRegisterService registerService ) => { if (!RegisterType.CheckIfIsValidType(request.Type, out bool isTransfer)) { throw new InvalidRegisterTypeException(); } if(!RegisterRepetitionType.CheckIfIsValidType(request.RepetitionType)) { throw new InvalidRegisterRepetitionTypeException(); } if(!Periodicities.CheckIfIsValidType(request.Periodicity)) { throw new InvalidPeriodicityException(); } await registerService.CreateOutcomeRegister(request, token); return Results.Ok(); } ); app.MapPost( "create-credit-card-outcome-register", [Authorize] async ( CancellationToken token, [FromBody] CreateCreditCardOutcomeRegisterRequest request, [FromServices] IRegisterService registerService ) => { if (!RegisterType.CheckIfIsValidType(request.Type, out bool isTransfer)) { throw new InvalidRegisterTypeException(); } if(!RegisterRepetitionType.CheckIfIsValidType(request.RepetitionType)) { throw new InvalidRegisterRepetitionTypeException(); } if(!Periodicities.CheckIfIsValidType(request.Periodicity)) { throw new InvalidPeriodicityException(); } await registerService.CreateCreditCardOutcomeRegister(request, token); return Results.Ok(); } ); app.MapPost( "create-transfer-register", [Authorize] async ( CancellationToken token, [FromBody] CreateTransferRegisterRequest request, [FromServices] IRegisterService registerService ) => { if (!RegisterType.CheckIfIsValidType(request.Type, out bool isTransfer)) { throw new InvalidRegisterTypeException(); } if(!RegisterRepetitionType.CheckIfIsValidType(request.RepetitionType)) { throw new InvalidRegisterRepetitionTypeException(); } if(!Periodicities.CheckIfIsValidType(request.Periodicity)) { throw new InvalidPeriodicityException(); } await registerService.CreateTransferRegister(request, token); return Results.Ok(); } );