public CompanyMSController(CompanyService company_service, IPODetailsService ipo_service, BoardMemberService bm_service, StockPriceService sp_service)
 {
     this.company_service = company_service;
     this.ipo_service     = ipo_service;
     this.bm_service      = bm_service;
     this.sp_service      = sp_service;
 }
        //private IRepository<StockExchange> repository;

        public StockExchangeController(StockExchangeService se_service, GetAllCompanyListService g_service, JoinCompanyStockExchangeService j_c_se_Service, StockPriceService sp_Service)
        {
            //this.repository = repository;
            this.se_service     = se_service;
            this.g_service      = g_service;
            this.j_c_se_Service = j_c_se_Service;
            this.sp_Service     = sp_Service;
        }
        public void ServiceTest_AddStockPrice()
        {
            var mockMapper     = new Mock <DtoMapper>();
            var mockRepository = new Mock <IStockPriceRepository>();

            mockRepository.Setup(x => x.AddStockPrice(It.IsAny <StockPrice>())).Returns(true);

            var service = new StockPriceService(mockRepository.Object, (IMapper)mockMapper.Object);
        }
示例#4
0
        /// <summary>
        /// Creates an instance of the StockServiceFacade
        /// </summary>
        /// <param name="stocks">+ separated string reperentation of the stocks</param>
        /// <param name="url">the web url to fetch the stocks</param>
        /// <param name="fields">fields requested to be fetched</param>
        public StockServiceFacade(string stocks, string url, string fields)
        {
            //intialize the fields
            _stocks = stocks;
            _url    = string.Format(url + fields, stocks);
            _fields = fields;


            //instantiat the StockPriceService to get the data
            _stockPriceService = new StockPriceService();
        }
示例#5
0
        public ActionResult Edit([Bind(Include = "ID,Code,Name,Exchange,Currency,Category,Price")] Stock stock)
        {
            if (ModelState.IsValid)
            {
                db.Entry(stock).State = EntityState.Modified;
                db.SaveChanges();

                StockPriceService.UpdateStockPrice(stock.Code);
                return(RedirectToAction("Index"));
            }
            return(View(stock));
        }
示例#6
0
        public UserAPITest()
        {
            var mockRepo = new Mock <IStockPriceRepository>();
            IList <StockPrice> stockPrice = new List <StockPrice>()
            {
                new StockPrice()
                {
                    StockId = 1, CompanyCode = "AAA", StockExchange = "NSE", CurrentPrice = 10, Date = Convert.ToDateTime("2019-06-08T00:00:00"), Time = "9:00:00"
                },
                new StockPrice()
                {
                    StockId = 2, CompanyCode = "BBB", StockExchange = "NSE", CurrentPrice = 10, Date = Convert.ToDateTime("2019-06-08T00:00:00"), Time = "9:00:00"
                },
                new StockPrice()
                {
                    StockId = 3, CompanyCode = "CCC", StockExchange = "NSE", CurrentPrice = 10, Date = Convert.ToDateTime("2019-06-08T00:00:00"), Time = "9:00:00"
                },
                new StockPrice()
                {
                    StockId = 4, CompanyCode = "DDD", StockExchange = "NSE", CurrentPrice = 10, Date = Convert.ToDateTime("2019-06-08T00:00:00"), Time = "9:00:00"
                },
                new StockPrice()
                {
                    StockId = 5, CompanyCode = "EEE", StockExchange = "NSE", CurrentPrice = 10, Date = Convert.ToDateTime("2019-06-08T00:00:00"), Time = "9:00:00"
                },
            };

            mockRepo.Setup(repo => repo.GetAllStockPrice()).Returns(stockPrice.ToList());
            mockRepo.Setup(repo => repo.GetStockPriceByName(It.IsAny <string>())).Returns((string i) => stockPrice.SingleOrDefault(x => x.CompanyCode == i));
            mockRepo.Setup(repo => repo.AddStockPrice(It.IsAny <StockPrice>())).Callback((StockPrice item) =>
            {
                item = new StockPrice()
                {
                    StockId = 6, CompanyCode = "FFF", StockExchange = "NSE", CurrentPrice = 10, Date = Convert.ToDateTime("2019-06-08T00:00:00"), Time = "9:00:00"
                };
                stockPrice.Add(item);
            }).Verifiable();
            mockRepo.Setup(repo => repo.DeleteStockPrice(It.IsAny <string>())).Callback((string item) =>
            {
                item = "BBB";
                stockPrice.Remove(stockPrice.SingleOrDefault(x => x.CompanyCode == item));
            }).Verifiable();
            mockRepo.SetupAllProperties();
            _service = new StockPriceService(mockRepo.Object);
        }
示例#7
0
        public async Task <IActionResult> OnGetAsync()
        {
            OriginalPrice = Settings.OriginalStockPrice;
            ShareCount    = Settings.ShareCount;
            var price = await StockPriceService.GetCurrentPriceAsync(Settings.StockSymbol);

            if (price == null)
            {
                return(NotFound());
            }
            CurrentPrice = price.Value;

            PriceHistory = await StockPriceService.GetPriceHistoryAsync(Settings.StockSymbol);

            if (PriceHistory == null)
            {
                return(NotFound());
            }

            return(Page());
        }
        public async Task StockPriceService_Should_Return_Result_For_A_Single_Day()
        {
            // Arrange
            var date = DateTime.Now;

            var stocks = new List <Stock>
            {
                new Stock
                {
                    Date     = date,
                    Exchange = "XNYS",
                    Close    = 2,
                    Open     = 1,
                    Symbol   = "EVR"
                },
                new Stock
                {
                    Date     = date.AddDays(-1),
                    Exchange = "XNYS",
                    Close    = 3,
                    Open     = 1,
                    Symbol   = "MSFT"
                }
            };

            _messageHandler.Setup(f => f.Send(It.IsAny <HttpRequestMessage>())).Returns(new HttpResponseMessage
            {
                Content = new StringContent(JsonConvert.SerializeObject(stocks))
            });

            var sut = new StockPriceService(new HttpClient(_messageHandler.Object));

            // Act
            var result = await sut.GetStockPricessByDateAsync(date);

            // Assert
            Assert.Single(result.ToList());
            Assert.Equal("XNYS", result.First().Exchange);
        }
示例#9
0
        protected override async Task OnInitializedAsync()
        {
            Prices = await StockPriceService.GetHistoricPrices(StockTicker);

            CompanyOutlook = await IuiStockService.GetCompanyOutlook(StockTicker);
        }