61 lines
2.1 KiB
C#
61 lines
2.1 KiB
C#
using Microsoft.Extensions.DependencyInjection;
|
|
using OemanTrader.Domain.Models;
|
|
using OemanTrader.Domain.Services;
|
|
using OemanTrader.Domain.Services.TransactionServices;
|
|
using OemanTrader.EntityFramework.Services;
|
|
using OemanTrader.FinantialModelingPrepAPI.Services;
|
|
using OemanTrader.WPF.ViewModels;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Configuration;
|
|
using System.Data;
|
|
using System.Linq;
|
|
using System.Threading.Tasks;
|
|
using System.Windows;
|
|
|
|
namespace OemanTrader.WPF
|
|
{
|
|
/// <summary>
|
|
/// Interaction logic for App.xaml
|
|
/// </summary>
|
|
public partial class App : Application
|
|
{
|
|
protected override async void OnStartup(StartupEventArgs e)
|
|
{
|
|
//new MajorIndexService().GetMajorIndex(Domain.Models.MajorIndexType.DowJones).ContinueWith((t) =>
|
|
//{
|
|
// var index = t.Result;
|
|
//});
|
|
|
|
IDataService<Account> accountService = new AccountDataService(new EntityFramework.OemanTraderDbContextFactory());
|
|
IStockPriceService stockPriceService = new StockPriceService(new FinantialModelingPrepAPI.FinancialModelingPrepHttpClientFactory("2035d4934632e1d7c38f15982e39d3aa"));
|
|
IBuyStockService buyStockService = new BuyStockService(stockPriceService, accountService);
|
|
|
|
Account buyer = await accountService.Get(1);
|
|
|
|
await buyStockService.BuyStock(buyer, "T", 5);
|
|
|
|
//new StockPriceService(new FinantialModelingPrepAPI.FinancialModelingPrepHttpClientFactory("2035d4934632e1d7c38f15982e39d3aa")).GetPrice("AAPL");
|
|
|
|
|
|
Window window = new MainWindow();
|
|
window.DataContext = new MainViewModel();
|
|
window.Show();
|
|
|
|
|
|
base.OnStartup(e);
|
|
}
|
|
|
|
private IServiceProvider CreateServiceProvider()
|
|
{
|
|
// 1. Singelton - one instance per application
|
|
// 2. Transient - different instance everytime
|
|
// 3. Scoped - one instance per "scope"
|
|
|
|
IServiceCollection services = new ServiceCollection();
|
|
return services.BuildServiceProvider();
|
|
|
|
}
|
|
}
|
|
}
|