-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
124 additions
and
4 deletions.
There are no files selected for viewing
16 changes: 16 additions & 0 deletions
16
...ication/SwiftParcel.ExternalAPI.Lecturer.Application/Events/Rejected/AddParcelRejected.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
namespace SwiftParcel.ExternalAPI.Lecturer.Application.Events.Rejected | ||
{ | ||
public class AddParcelRejected | ||
{ | ||
public Guid ParcelId { get; } | ||
public string Reason { get; } | ||
public string Code { get; } | ||
|
||
public AddParcelRejected(Guid parcelId, string reason, string code) | ||
{ | ||
ParcelId = parcelId; | ||
Reason = reason; | ||
Code = code; | ||
} | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
...ation/SwiftParcel.ExternalAPI.Lecturer.Application/Events/Rejected/CancelOrderRejected.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
using Convey.CQRS.Events; | ||
|
||
namespace SwiftParcel.ExternalAPI.Lecturer.Application.Events.Rejected | ||
{ | ||
public class CancelOrderRejected : IRejectedEvent | ||
{ | ||
public Guid OrderId { get; } | ||
public string Reason { get; } | ||
public string Code { get; } | ||
|
||
public CancelOrderRejected(Guid orderId, string reason, string code) | ||
{ | ||
OrderId = orderId; | ||
Reason = reason; | ||
Code = code; | ||
} | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
...tion/SwiftParcel.ExternalAPI.Lecturer.Application/Events/Rejected/ConfirmOrderRejected.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
using Convey.CQRS.Events; | ||
|
||
namespace SwiftParcel.ExternalAPI.Lecturer.Application.Events.Rejected | ||
{ | ||
public class ConfirmOrderRejected : IRejectedEvent | ||
{ | ||
public Guid OrderId { get; } | ||
public string Reason { get; } | ||
public string Code { get; } | ||
|
||
public ConfirmOrderRejected (Guid orderId, string reason, string code) | ||
{ | ||
OrderId = orderId; | ||
Reason = reason; | ||
Code = code; | ||
} | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
...ation/SwiftParcel.ExternalAPI.Lecturer.Application/Events/Rejected/CreateOrderRejected.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
using Convey.CQRS.Events; | ||
|
||
namespace SwiftParcel.ExternalAPI.Lecturer.Application.Events.Rejected | ||
{ | ||
public class CreateOrderRejected : IRejectedEvent | ||
{ | ||
public Guid OrderId { get; } | ||
public Guid CustomerId { get; } | ||
public Guid ParcelId { get; } | ||
public string Reason { get; } | ||
public string Code { get; } | ||
|
||
public CreateOrderRejected(Guid orderId, Guid customerId, Guid parcelId, string reason, string code) | ||
{ | ||
OrderId = orderId; | ||
CustomerId = customerId; | ||
ParcelId = parcelId; | ||
Reason = reason; | ||
Code = code; | ||
} | ||
} | ||
} |
46 changes: 46 additions & 0 deletions
46
...re/SwiftParcel.ExternalAPI.Lecturer.Infrastructure/Exceptions/ExceptionToMessageMapper.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
using Convey.MessageBrokers.RabbitMQ; | ||
using SwiftParcel.ExternalAPI.Lecturer.Application.Exceptions; | ||
using SwiftParcel.ExternalAPI.Lecturer.Application.Commands; | ||
using SwiftParcel.ExternalAPI.Lecturer.Application.Events.Rejected; | ||
|
||
namespace SwiftParcel.ExternalAPI.Lecturer.Infrastructure.Exceptions | ||
{ | ||
public class ExceptionToMessageMapper : IExceptionToMessageMapper | ||
{ | ||
public object Map(Exception exception, object message) | ||
=> exception switch | ||
{ | ||
InquiresServiceConnectionException ex => message switch | ||
{ | ||
AddParcel m => new AddParcelRejected(m.ParcelId, ex.Message, ex.Code), | ||
_ => null | ||
}, | ||
InquiresServiceException ex => message switch | ||
{ | ||
AddParcel m => new AddParcelRejected(m.ParcelId, ex.Message, ex.Code), | ||
_ => null | ||
}, | ||
OffersServiceConnectionException ex => message switch | ||
{ | ||
CreateOrder m => new CreateOrderRejected(m.OrderId, m.CustomerId, m.ParcelId, ex.Message, ex.Code), | ||
ConfirmOrder m => new ConfirmOrderRejected(m.OrderId, ex.Message, ex.Code), | ||
CancelOrder m => new CancelOrderRejected(m.OrderId, ex.Message, ex.Code), | ||
_ => null | ||
}, | ||
OffersServiceException ex => message switch | ||
{ | ||
CreateOrder m => new CreateOrderRejected(m.OrderId, m.CustomerId, m.ParcelId, ex.Message, ex.Code), | ||
ConfirmOrder m => new ConfirmOrderRejected(m.OrderId, ex.Message, ex.Code), | ||
CancelOrder m => new CancelOrderRejected(m.OrderId, ex.Message, ex.Code), | ||
_ => null | ||
}, | ||
OfferNotFoundException ex => message switch | ||
{ | ||
ConfirmOrder m => new ConfirmOrderRejected(m.OrderId, ex.Message, ex.Code), | ||
CancelOrder m => new CancelOrderRejected(m.OrderId, ex.Message, ex.Code), | ||
_ => null | ||
}, | ||
_ => null | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters