/// <summary> /// IActionResult is a common contract interface for returnig /// ViewResult(), PartialViewresult(), OkResult(), OkObjectResult() /// Returns type for MVC Controller Action methods and /// API Controller Action methods /// </summary> /// <returns></returns> public async Task <IActionResult> Index() { List <Products> result = new List <Products>(); if (TempData.Keys.Count > 0) { //var cat = TempData.GetData<Categories>("Cat"); // var id = Convert.ToInt32(TempData["CatRowId"]); var id = HttpContext.Session.GetInt32("CatId"); result = prdRepository.GetDataAsync().Result.ToList().Where(p => p.CategoryRowId == id).ToList(); } else { result = await prdRepository.GetDataAsync(); } return(View(result)); }
public IActionResult Create() { ViewData["CategoryRowId"] = catRepository.GetDataAsync().Result; return(View(new Products())); }
/// <summary> /// IActionResult is a common contract interface for returnig /// ViewResult(), PartialViewresult(), OkResult(), OkObjectResult() /// Returns type for MVC Controller Action methods and /// API Controller Action methods /// </summary> /// <returns></returns> public async Task <IActionResult> Index() { var result = await catRepository.GetDataAsync(); return(View(result)); }
public async Task <IActionResult> Get() { var result = await catRepository.GetDataAsync(); return(Ok(result)); // response will be serialized in JSON format }