Add error handling and update history query logic
- Introduced a using directive for exceptions in DocumentCreateReadSQL.cs. - Enhanced CreateParmas method with try-catch for base64 conversion errors, throwing BadRequestException on failure. - Added switch statement in HistoryController.cs to manage Related property in ReadHistoryQuery, setting flags for receiver and sender.
This commit is contained in:
parent
8b1199bc71
commit
9b945ce232
@ -1,5 +1,6 @@
|
|||||||
using Dapper;
|
using Dapper;
|
||||||
using EnvelopeGenerator.Application.Contracts.SQLExecutor;
|
using EnvelopeGenerator.Application.Contracts.SQLExecutor;
|
||||||
|
using EnvelopeGenerator.Application.Exceptions;
|
||||||
using EnvelopeGenerator.Domain.Entities;
|
using EnvelopeGenerator.Domain.Entities;
|
||||||
|
|
||||||
namespace EnvelopeGenerator.Application.SQL;
|
namespace EnvelopeGenerator.Application.SQL;
|
||||||
@ -34,9 +35,16 @@ public class DocumentCreateReadSQL : ISQL<EnvelopeDocument>
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static DynamicParameters CreateParmas(string base64)
|
public static DynamicParameters CreateParmas(string base64)
|
||||||
{
|
{
|
||||||
var parameters = new DynamicParameters();
|
try
|
||||||
byte[] byteData = Convert.FromBase64String(base64);
|
{
|
||||||
parameters.Add("ByteData", byteData, System.Data.DbType.Binary);
|
var parameters = new DynamicParameters();
|
||||||
return parameters;
|
byte[] byteData = Convert.FromBase64String(base64);
|
||||||
|
parameters.Add("ByteData", byteData, System.Data.DbType.Binary);
|
||||||
|
return parameters;
|
||||||
|
}
|
||||||
|
catch(FormatException ex)
|
||||||
|
{
|
||||||
|
throw new BadRequestException(ex.Message.Replace("input", "dataAsBase64"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -109,9 +109,7 @@ public class HistoryController : ControllerBase
|
|||||||
{
|
{
|
||||||
bool withReceiver = false;
|
bool withReceiver = false;
|
||||||
bool withSender = false;
|
bool withSender = false;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
switch (history.Related)
|
switch (history.Related)
|
||||||
{
|
{
|
||||||
case ReferenceType.Receiver:
|
case ReferenceType.Receiver:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user