Example #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);
            }));
        }
        public async Task <IActionResult> Execute(JObject jObj)
        {
            if (jObj == null)
            {
                throw new ArgumentNullException(nameof(jObj));
            }

            var parameter    = _requestBuilder.GetSearchFeedItems(jObj);
            var searchResult = await _feedRepository.Search(parameter);

            _halResponseBuilder.AddLinks(l => l.AddSelf(GetFeedItemsLink()));
            if (searchResult != null && searchResult.Content != null)
            {
                var feedItems = searchResult.Content;
                foreach (var feedItem in feedItems)
                {
                    _halResponseBuilder.AddEmbedded(e => e.AddObject(_responseBuilder.GetFeedItem(feedItem)));
                }

                double r       = (double)searchResult.TotalResults / (double)parameter.Count;
                var    nbPages = Math.Ceiling(r);
                nbPages = nbPages == 0 ? 1 : nbPages;
                for (var page = 1; page <= nbPages; page++)
                {
                    _halResponseBuilder.AddLinks(l => l.AddOtherItem("navigation", new Dtos.Link(GetFeedItemsLink(), page.ToString())));
                }
            }

            return(new OkObjectResult(_halResponseBuilder.Build()));
        }
Example #3
0
        public void Enrich(IHalResponseBuilder halResponseBuilder, ShopCategoryAggregate category)
        {
            if (halResponseBuilder == null)
            {
                throw new ArgumentNullException(nameof(halResponseBuilder));
            }

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

            halResponseBuilder.AddEmbedded(e => e.AddObject(_responseBuilder.GetShopCategory(category), (l) => l.AddSelf(@"/" + Constants.RouteNames.ShopCategories + "/" + category.Id)));
        }
Example #4
0
        public void Enrich(IHalResponseBuilder halResponseBuilder, TagAggregate tag)
        {
            if (halResponseBuilder == null)
            {
                throw new ArgumentNullException(nameof(halResponseBuilder));
            }

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

            halResponseBuilder.AddEmbedded(e => e.AddObject(_responseBuilder.GetTag(tag), (l) => l.AddSelf(@"/" + Constants.RouteNames.Tags + "/" + tag.Name)));
        }
        public void Enrich(IHalResponseBuilder halResponseBuilder, DiscountAggregate discountAggregate)
        {
            if (halResponseBuilder == null)
            {
                throw new ArgumentNullException(nameof(halResponseBuilder));
            }

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

            halResponseBuilder.AddEmbedded(e => e.AddObject(_responseBuilder.GetDiscount(discountAggregate)));
        }
Example #6
0
        public void Enrich(IHalResponseBuilder halResponseBuilder, ServiceComment serviceComment, string serviceId)
        {
            if (halResponseBuilder == null)
            {
                throw new ArgumentNullException(nameof(halResponseBuilder));
            }

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

            halResponseBuilder.AddEmbedded(e => e.AddObject(_responseBuilder.GetServiceComment(serviceComment),
                                                            (l) => l.AddOtherItem("service", new Dtos.Link("/" + Constants.RouteNames.Services + "/" + serviceId))));
        }
        public void Enrich(IHalResponseBuilder halResponseBuilder, ProductComment productComment, string productId)
        {
            if (halResponseBuilder == null)
            {
                throw new ArgumentNullException(nameof(halResponseBuilder));
            }

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

            halResponseBuilder.AddEmbedded(e => e.AddObject(_responseBuilder.GetProductComment(productComment),
                                                            (l) => l.AddOtherItem("product", new Dtos.Link("/" + Constants.RouteNames.Products + "/" + productId))));
        }
        public void Enrich(IHalResponseBuilder halResponseBuilder, ServiceResultLine serviceResultLine)
        {
            if (halResponseBuilder == null)
            {
                throw new ArgumentNullException(nameof(halResponseBuilder));
            }

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

            halResponseBuilder.AddEmbedded(e => e.AddObject(_responseBuilder.GetServiceOccurrence(serviceResultLine),
                                                            (l) =>
            {
                l.AddOtherItem("shop", new Dtos.Link("/" + Constants.RouteNames.Shops + "/" + serviceResultLine.ShopId)).AddSelf(Constants.RouteNames.Services + "/" + serviceResultLine.Id);
            }));
        }
        public void Enrich(IHalResponseBuilder halResponseBuilder, MessageAggregate message)
        {
            if (halResponseBuilder == null)
            {
                throw new ArgumentNullException(nameof(halResponseBuilder));
            }

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

            halResponseBuilder.AddEmbedded(e => e.AddObject(_responseBuilder.GetMessage(message),
                                                            (l) =>
            {
                l.AddSelf(Constants.RouteNames.Messages + "/" + message.Id);
            }));
        }
        public void Enrich(IHalResponseBuilder halResponseBuilder, NotificationAggregate notification)
        {
            if (halResponseBuilder == null)
            {
                throw new ArgumentNullException(nameof(halResponseBuilder));
            }

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

            halResponseBuilder.AddEmbedded(e => e.AddObject(_responseBuilder.GetNotification(notification),
                                                            (l) =>
            {
                l.AddSelf(Constants.RouteNames.Notifications + "/" + notification.Id);
            }));
        }
        public void Enrich(IHalResponseBuilder halResponseBuilder, ProductAggregate product)
        {
            if (halResponseBuilder == null)
            {
                throw new ArgumentNullException(nameof(halResponseBuilder));
            }

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

            halResponseBuilder.AddEmbedded(e => e.AddObject(_responseBuilder.GetProduct(product),
                                                            (l) =>
            {
                l.AddOtherItem("shop", new Dtos.Link("/" + Constants.RouteNames.Shops + "/" + product.ShopId)).AddSelf(Constants.RouteNames.Products + "/" + product.Id);
            }));
        }
        public void Enrich(IHalResponseBuilder halResponseBuilder, ClientServiceAggregate announcement)
        {
            if (halResponseBuilder == null)
            {
                throw new ArgumentNullException(nameof(halResponseBuilder));
            }

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

            halResponseBuilder.AddEmbedded(e => e.AddObject(_responseBuilder.GetClientService(announcement),
                                                            (l) =>
            {
                if (announcement.Category == null)
                {
                    return;
                }

                l.AddOtherItem("category", new Dtos.Link("/" + Constants.RouteNames.ShopCategories + "/" + announcement.CategoryId)).AddSelf(Constants.RouteNames.ClientServices + "/" + announcement.Id);
            }));
        }
Example #13
0
        public void Enrich(IHalResponseBuilder halResponseBuilder, ShopAggregate shop)
        {
            halResponseBuilder.AddEmbedded(e => e.AddObject(_responseBuilder.GetShop(shop),
                                                            (l) =>
            {
                l.AddOtherItem("category", new Dtos.Link("/" + Constants.RouteNames.ShopCategories + "/" + shop.CategoryId, shop.ShopCategory.Name)).AddSelf(Constants.RouteNames.Shops + "/" + shop.Id);
                if (shop.ShopFilters != null && shop.ShopFilters.Any())
                {
                    foreach (var filter in shop.ShopFilters)
                    {
                        l.AddOtherItem("filters", new Dtos.Link("/" + Constants.RouteNames.Filers + "/" + filter.Id, filter.Name));
                    }
                }

                if (shop.ProductCategories != null && shop.ProductCategories.Any())
                {
                    foreach (var productCategory in shop.ProductCategories)
                    {
                        l.AddOtherItem("productCategories", new Dtos.Link("/" + Constants.RouteNames.Filers + "/" + productCategory.Id, productCategory.Name));
                    }
                }
            }));
        }