Multiple implementations of the same back-end application. The aim is to provide quick, side-by-side comparisons of different technologies (languages, frameworks, libraries) while preserving consistent business logic across all implementations.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

27 lines
707 B

#include "AddItem.h"
#include <stdexcept>
namespace nxl::autostore::application {
AddItem::AddItem(IItemRepository& itemRepository, IClock& clock,
IOrderService& orderService)
: itemRepository(itemRepository), clock(clock), orderService(orderService)
{}
void AddItem::execute(domain::Item&& item, const ItemPresenter& presenter)
{
try {
const auto currentTime = clock.getCurrentTime();
if (expirationPolicy.isExpired(item, currentTime)) {
orderService.orderItem(item);
}
item.id = itemRepository.save(item);
presenter(item); // Success
} catch (const std::exception& e) {
presenter(item); // Failure
}
}
} // namespace nxl::autostore::application