Exemplo n.º 1
0
        public void HandleEvent(EntityInserted <Customer> eventMessage)
        {
            // There is no need to send webhooks for guest customers.
            if (eventMessage.Entity.IsGuest())
            {
                return;
            }

            CustomerDto customer = _customerApiService.GetCustomerById(eventMessage.Entity.Id);

            _webHookManager.NotifyAllAsync(WebHookNames.CustomerCreated, new { Item = customer });
        }
Exemplo n.º 2
0
        public OrderDto PrepareOrderDTO(Order order)
        {
            try
            {
                var orderDto = order.ToDto();

                orderDto.OrderItems = _orderService.GetOrderItems(order.Id).Select(PrepareOrderItemDTO).ToList();
                orderDto.Shipments  = _shipmentService.GetShipmentsByOrderId(order.Id).Select(PrepareShippingItemDTO).ToList();

                var billingAddress = _addressService.GetAddressById(order.BillingAddressId);
                orderDto.BillingAddress = billingAddress.ToDto();

                if (order.ShippingAddressId.HasValue)
                {
                    var shippingAddress = _addressService.GetAddressById(order.ShippingAddressId.Value);
                    orderDto.ShippingAddress = shippingAddress.ToDto();
                }

                var customerDto = _customerApiService.GetCustomerById(order.CustomerId);

                if (customerDto != null)
                {
                    orderDto.Customer = customerDto.ToOrderCustomerDto();
                }

                return(orderDto);
            }
            catch (Exception ex)
            {
                throw;
            }
        }
Exemplo n.º 3
0
        public void HandleEvent(EntityInserted <Customer> eventMessage)
        {
            // There is no need to send webhooks for guest customers.
            if (eventMessage.Entity.IsGuest())
            {
                return;
            }

            CustomerDto customer = _customerApiService.GetCustomerById(eventMessage.Entity.Id);
            var         storeIds = new List <int>();

            if (customer.RegisteredInStoreId.HasValue)
            {
                storeIds.Add(customer.RegisteredInStoreId.Value);
            }

            NotifyRegisteredWebHooks(customer, WebHookNames.CustomersCreate, storeIds);
        }
Exemplo n.º 4
0
        public OrderDto PrepareOrderDTO(Order order)
        {
            OrderDto orderDto = order.ToDto();

            CustomerDto customerDto = _customerApiService.GetCustomerById(order.Customer.Id);

            if (customerDto != null)
            {
                orderDto.Customer = customerDto.ToOrderCustomerDto();
            }

            return(orderDto);
        }
Exemplo n.º 5
0
        public OrderDto PrepareOrderDTO(Order order)
        {
            OrderDto orderDto = order.ToDto();

            orderDto.OrderItemDtos = order.OrderItems.Select(orderItem => PrepareOrderItemDTO(orderItem)).ToList();

            CustomerDto customerDto = _customerApiService.GetCustomerById(order.Customer.Id);

            if (customerDto != null)
            {
                orderDto.Customer = customerDto.ToOrderCustomerDto();
            }

            return(orderDto);
        }
        public OrderDto PrepareOrderDTO(Order order)
        {
            var orderDto = order.ToDto();

            var checkoutAttributes = _checkoutAttributeParser.ParseCheckoutAttributeValues(order.CheckoutAttributesXml);
            var commentAttribute   = checkoutAttributes.FirstOrDefault(x => x.Name.Equals("kommentar", StringComparison.InvariantCultureIgnoreCase));

            if (commentAttribute != null)
            {
                orderDto.Comment = commentAttribute.Name;
            }

            var customerDto = _customerApiService.GetCustomerById(order.Customer.Id);

            if (customerDto != null)
            {
                orderDto.Customer = customerDto.ToOrderCustomerDto();
            }

            return(orderDto);
        }
        public IActionResult GetCustomerById(int id, string fields = "")
        {
            if (id <= 0)
            {
                return(Error(HttpStatusCode.BadRequest, "id", "invalid id"));
            }

            var customer = _customerApiService.GetCustomerById(id);

            if (customer == null)
            {
                return(Error(HttpStatusCode.NotFound, "customer", "not found"));
            }

            var customersRootObject = new CustomersRootObject();

            customersRootObject.Customers.Add(customer);

            var json = JsonFieldsSerializer.Serialize(customersRootObject, fields);

            return(new RawJsonActionResult(json));
        }