public async Task <IActionResult> Index(IEnumerable <MedicineDemand> demands) { try { if (HttpContext.Session.GetString("token") == null) { _log.Info("token not found"); return(RedirectToAction("Login", "User")); } else { _token = HttpContext.Session.GetString("token"); _response = await _demandProvider.GetSupply(demands.ToList(), _token); if (_response.IsSuccessStatusCode) { _log.Info("Supply received"); var result = await _response.Content.ReadAsStringAsync(); TempData["supply"] = result; return(RedirectToAction("DisplaySupply")); } else if (_response.StatusCode == HttpStatusCode.NotFound) { _log.Error("error while getting supply"); return(View("NoStock")); } else if (_response.StatusCode == HttpStatusCode.Unauthorized) { return(View("Unauthorized")); } else { return(View("Error")); } } } catch (Exception e) { _log.Error("Error while getting demand list in DemandController for user : "******"userName") + " - " + e.Message); return(View("Error")); } }
public async Task <IActionResult> Index(IEnumerable <MedicineDemand> demands) { try { if (HttpContext.Session.GetString("token") == null) { return(RedirectToAction("Login", "User")); } else { _token = HttpContext.Session.GetString("token"); _response = await _demandProvider.GetSupply(demands.ToList(), _token); if (_response.IsSuccessStatusCode) { var result = await _response.Content.ReadAsStringAsync(); TempData["supply"] = result; return(RedirectToAction("DisplaySupply")); } else if (_response.StatusCode == HttpStatusCode.NotFound) { return(View("NoSupply")); } else if (_response.StatusCode == HttpStatusCode.Unauthorized) { return(View("Unauthorized")); } else { return(View("Error")); } } } catch (Exception) { return(View("Error")); } }