public IActionResult SwingValue(NSEInsiderResponse request) { try { if (request.IsNull() || !request.Symbols.HasRecords() || request.Cookie.IsNull()) { return(View(new NSEInsiderResponse() { ErrorMessage = CommonError.InvalidRequest })); } TempData["Cookie"] = request.Cookie; TempData["Symbols"] = request.Symbols; List <StockData> stocks = new List <StockData>(); List <string> symbols = request.Symbols.Split(',').ToList(); foreach (var symbol in symbols) { var price = GetAveragePrice(symbol, request.Cookie); if (price == -1) { break; } else { stocks.Add(new StockData() { Symbol = symbol, AveragePrice = price }); } } if (!stocks.HasRecords()) { return(View(new NSEInsiderResponse() { IsCookieRequired = true, ErrorMessage = CommonError.CookieExpired })); } return(View(new NSEInsiderResponse() { IsSuccess = true, Stocks = stocks, Cookie = request.Cookie })); } catch (Exception) { return(View(new NSEInsiderResponse() { IsCookieRequired = true, ErrorMessage = CommonError.CookieExpired })); } }