Beispiel #1
0
        public async Task <ActionResult> Create(IFormCollection formCollection)
        {
            foreach (var key in formCollection.Keys)
            {
                ViewBag.DisplayStock = formCollection["nameOfStock"];
            }


            var name = formCollection["nameOfStock"].ToString();

            var msg = new StockNameModel();

            msg.stockName = name;

            var content = new StringContent(JsonConvert.SerializeObject(msg), Encoding.UTF8, "application/json");
            HttpResponseMessage response = await client.PostAsync("https://cs4471-stocksummaryandcomparisonservice.azurewebsites.net/api/StockSummary", content);

            response.EnsureSuccessStatusCode();

            if (!response.IsSuccessStatusCode)
            {
                return(View());
            }
            var data = JsonConvert.DeserializeObject <StockSummaryInfo>(response.Content.ReadAsStringAsync().Result);

            ViewBag.lowdata        = data.low;
            ViewBag.highdata       = data.high;
            ViewBag.marketCap      = data.marketCap;
            ViewBag.priceEarnRatio = data.priceToEarnRatio;
            return(View());
        }
Beispiel #2
0
        public ServerResponse createMail(int id, [FromBody] StockNameModel stock)
        {
            ServerResponse sr;
            bool           success = true;
            string         message = "";

            if (stock == null)
            {
                success = false;
                message = "no stock given";
            }

            if (success)
            {
                sr = UserUtilities.addMail(id, stock.stock);
            }
            else
            {
                sr = new ServerResponse(success, message, null);
            }

            return(sr);
        }