コード例 #1
0
        //[HttpGet("v/Order/{orderId}", Title = "GetOrdersRoute")]
        public async Task <IActionResult> GetOrder(string orderId, [FromHeader(Name = "x-correlationToken")] string correlationToken)
        {
            Guard.ForNullOrEmpty(orderId, "orderid");
            Guard.ForNullOrEmpty(correlationToken, "correlationToken");

            var order = await _orderQueries.GetOrder(orderId, correlationToken);

            if (order == null)
            {
                return(BadRequest("Order does not exist"));
            }

            return(new ObjectResult(RestMapper.MapToOrderDto(order)));
        }
コード例 #2
0
 public static IFluentRestBuilder AddRestMapper <TInput, TOutput>(
     this IFluentRestBuilder builder,
     Func <TInput, TOutput> mapping,
     Action <RestMapper <TInput, TOutput> > configuration = null)
     where TOutput : RestEntity
 {
     builder.Services.AddScoped <IMapper <TInput, TOutput> >(
         serviceProvider =>
     {
         var urlHelper = serviceProvider.GetService <IScopedStorage <IUrlHelper> >()?.Value
                         ?? serviceProvider.GetService <IUrlHelper>();
         var mapper = new RestMapper <TInput, TOutput>(mapping, urlHelper);
         configuration?.Invoke(mapper);
         return(mapper);
     });
     return(builder);
 }
コード例 #3
0
        //[HttpGet("v{version:apiVersion}/Orders", Title = "GetAllOrdersRoute")]
        public async Task <IActionResult> GetOrders([FromHeader(Name = "x-correlationToken")] string correlationToken)
        {
            _telemetryClient.TrackEvent(
                $"Publishing EmptyBasketEvent from CheckOutEventHandler in Ordering.API for Request {correlationToken} ");



            Guard.ForNullOrEmpty(correlationToken, "correlationToken");

            var orders = await _orderQueries.GetOrders(correlationToken);

            if (orders == null || orders.Count < 1)
            {
                return(BadRequest("Orders do not exist"));
            }

            return(new ObjectResult(RestMapper.MapToOrdersDto(orders)));
        }
コード例 #4
0
        public static void Setup(IEventStore eventStore)
        {
            Contracts.ContractCollection.Setup();

            Describe.Class <GetCurve.Curve>()
            .Property(x => x.Instruments).Are(Schema.instrument)
            .Property(x => x.Name).Is(Schema.name);

            var getCurve = RestMapper.TryMapQuery <GetCurve, GetCurve.Curve?>(MarketCurveSingleUrl, (c) => c is null ? null : new Dictionary <string, object>
            {
                ["@id"]         = MarketCurveSingleUrl.Replace(@"{id}", c.Id),
                [Schema.name]   = c.Name,
                ["instruments"] = c.Instruments,
            });

            var getCurveList = RestMapper.TryMapQuery <GetCurveList, CurveList>(MarketCurvesUrl, (curves) => new Dictionary <string, object>
            {
                ["curves"] = curves.Curves.Select(c => new Dictionary <string, object>
                {
                    ["@id"]       = getCurve.WithRouteValues(new { id = c.Id }).Href,
                    [Schema.name] = c.Name
                })
            });

            var nameAndAddInstrument = RestMapper.TryMapCommand <MarketCurve.Aggregate, MarketCurve.State, NameAndAddInstrument>(MarketCurvesUrl, new NameAndAddInstrument(string.Empty, string.Empty));

            RestMapper.TryMapCommand <MarketCurve.Aggregate, MarketCurve.State, AddInstrument>(AddInstrumentUrl, new AddInstrument(string.Empty));


            RestMapper.TryMapIndex(getCurveList.Yield());

            EventMapper.TryMap <InstrumentAddedToCurve>("instrument added");
            EventMapper.TryMap <MarketCurveNamed>("market curve named");

            RestMapper.SetEventStore(eventStore);
        }