public static Task WithQuotesAsync(this IWorkContextBuilder builder, Store store, User user, Currency currency, Language language) { var serviceProvider = builder.HttpContext.RequestServices; var quoteRequestBuilder = serviceProvider.GetRequiredService <IQuoteRequestBuilder>(); Func <Model.Quote.QuoteRequest> factory = () => { quoteRequestBuilder.GetOrCreateNewTransientQuoteRequestAsync(store, user, language, currency).GetAwaiter().GetResult(); return(quoteRequestBuilder.QuoteRequest); }; return(builder.WithQuotesAsync(factory)); }
public static Task WithQuotesAsync(this IWorkContextBuilder builder, Store store, User user, Currency currency, Language language) { var serviceProvider = builder.HttpContext.RequestServices; var quoteRequestBuilder = serviceProvider.GetRequiredService <IQuoteRequestBuilder>(); Func <Model.Quote.QuoteRequest> factory = () => { Task.Factory.StartNew(() => quoteRequestBuilder.GetOrCreateNewTransientQuoteRequestAsync(store, user, language, currency), CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult(); return(quoteRequestBuilder.QuoteRequest); }; return(builder.WithQuotesAsync(factory)); }