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
1 parent
73ac3a9
commit 5b1da2a
Showing
9 changed files
with
101 additions
and
2 deletions.
There are no files selected for viewing
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
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
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
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,37 @@ | ||
using System; | ||
using Restbucks.Service.Domain; | ||
using Restbucks.Service.Mappers; | ||
using Restbucks.Service.Representations; | ||
|
||
namespace Restbucks.Service.Activities | ||
{ | ||
public class CompleteOrderActivity : ICompleteOrderActivity | ||
{ | ||
private readonly IOrderRepository _repository; | ||
private readonly OrderRepresentationMapper _orderRepresentationMapper; | ||
|
||
public CompleteOrderActivity(IOrderRepository repository, OrderRepresentationMapper orderRepresentationMapper) | ||
{ | ||
_repository = repository; | ||
_orderRepresentationMapper = orderRepresentationMapper; | ||
} | ||
|
||
public OrderRepresentation Complete(int orderId) | ||
{ | ||
var order = _repository.FindById(orderId); | ||
if (order == null) | ||
{ | ||
throw new NoSuchOrderException(orderId); | ||
} | ||
|
||
if (order.Status != OrderStatus.Ready) | ||
{ | ||
throw new UnexpectedOrderStateException(orderId); | ||
} | ||
order.Take(); | ||
|
||
var representation = _orderRepresentationMapper.GetRepresentation(order); | ||
return representation; | ||
} | ||
} | ||
} |
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,9 @@ | ||
using Restbucks.Service.Representations; | ||
|
||
namespace Restbucks.Service.Activities | ||
{ | ||
public interface ICompleteOrderActivity | ||
{ | ||
OrderRepresentation Complete(int orderId); | ||
} | ||
} |
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
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
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
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