public async Task TestWebsiteDetailsLineItem()
        {
            #region data and mock
            var websiteDetailsLineItem = new WebsiteDetailsLineItemModel
            {
                Category       = "test",
                Notes          = "Test Note",
                WebsiteDetails = new WebsiteDetailsProduct
                {
                    TemplateId = "Test Id",
                }
            };

            _websiteDetailRepositoryMock.Setup(c => c.Save(It.IsAny <WebsiteDetail>())).Returns(1);

            var inputLineItems = new List <LineItemModel> {
                websiteDetailsLineItem
            };
            #endregion

            var result = await _lineItemService.CreateLineItemsAsync(inputLineItems).ConfigureAwait(false);

            result.Should().NotBeNullOrEmpty("Line items must be created");
            result.Count.Should().Be(1, "Line items must be created");
            result.First().WebsiteDetail.Should().NotBeNull("Web site detail line item should be created");
            result.First().AdWordCampaign.Should().BeNull("Add word campaign should not exist");
        }
Beispiel #2
0
        /// <summary>
        /// Save order
        ///
        /// </summary>
        /// <returns>Order</returns>
        public async Task <Order> SaveOrderAsync(OrderModel inputOrder)
        {
            Guard.IsNotNull(inputOrder, () => inputOrder);

            Order result = null;
            var   order  = MapperHelper.MapToOrder(inputOrder);

            var lineItems = await _lineItemService.CreateLineItemsAsync(inputOrder?.LineItems).ConfigureAwait(false);

            order.LineItems = lineItems;

            var customer = MapperHelper.MapToCustomer(inputOrder?.AdditionalFields?.Customer);

            if (customer != null)
            {
                var customerId = _customerRepository.Save(customer);
                order.Customer = _customerRepository.Get(customerId);
            }

            var additionalInfo = MapperHelper.MapToAdditionalInfo(inputOrder?.AdditionalFields?.AdditionalInfo);

            if (additionalInfo != null)
            {
                var additionalInfoId = _additionalInfoRepository.Save(additionalInfo);
                order.AdditionalInfo = _additionalInfoRepository.Get(additionalInfoId);
            }

            var id = _orderRepository.Save(order);

            result = _orderRepository.Get(id);

            return(result);
        }