Пример #1
0
        public async Task Enrich(IHalResponseBuilder halResponseBuilder, OrderAggregate order)
        {
            if (halResponseBuilder == null)
            {
                throw new ArgumentNullException(nameof(halResponseBuilder));
            }

            if (order == null)
            {
                throw new ArgumentNullException(nameof(order));
            }

            if (order.Status == OrderAggregateStatus.Created)
            {
                await _orderPriceCalculatorHelper.Update(order);
            }

            halResponseBuilder.AddEmbedded(e => e.AddObject(_responseBuilder.GetOrder(order),
                                                            (l) =>
            {
                l.AddOtherItem("shop", new Dtos.Link("/" + Constants.RouteNames.Shops + "/" + order.ShopId));
                l.AddOtherItem("user", new Dtos.Link("/" + Constants.RouteNames.Users + "/" + order.Subject));
                l.AddSelf(Constants.RouteNames.Orders + "/" + order.Id);
            }));
        }