public IActionResult Index(int CategoryType = 0) { try { IndexAssetsExpiryViewModel objIndexAssetsExpiryViewModel = new IndexAssetsExpiryViewModel(); IEnumerable <AssetsExpiryViewModel> objAssetsExpiryViewModelList = null; string endpoint = assetsApiBaseUrl + "ProductExpiry"; Task <string> HttpGetResponse = CommonFunction.GetWebAPI(endpoint); if (HttpGetResponse != null) { objAssetsExpiryViewModelList = JsonConvert.DeserializeObject <IEnumerable <AssetsExpiryViewModel> >(HttpGetResponse.Result).ToList(); } else { objAssetsExpiryViewModelList = Enumerable.Empty <AssetsExpiryViewModel>().ToList(); ModelState.AddModelError(string.Empty, "Server error. Please contact administrator."); } if (CategoryType > 0) { objIndexAssetsExpiryViewModel.AssetsExpiryViewModelList = objAssetsExpiryViewModelList.Where(a => a.MasterCategoryType == CategoryType).OrderBy(a => a.ProductTitle).ToList(); } else { objIndexAssetsExpiryViewModel.AssetsExpiryViewModelList = objAssetsExpiryViewModelList.OrderBy(a => a.ProductTitle).ToList(); } //############# Profile Maping ################### CPanelManager.ViewModels.Account.ValidateAccountViewModel objValidateAccountViewModel = CommonFunction.ActionResultAuthentication(HttpContext, "/MasterProduct/Index"); if (objValidateAccountViewModel != null) { objIndexAssetsExpiryViewModel.IsSelect = objValidateAccountViewModel.IsSelect; objIndexAssetsExpiryViewModel.IsInsert = objValidateAccountViewModel.IsInsert; objIndexAssetsExpiryViewModel.IsUpdate = objValidateAccountViewModel.IsUpdate; objIndexAssetsExpiryViewModel.IsDelete = objValidateAccountViewModel.IsDelete; } //############# Profile Maping End ################### objIndexAssetsExpiryViewModel.MasterCategoryType = CategoryType; //Return View doesn't make a new requests, it just renders the view return(View("~/Views/Assets/AssetsExpiry/Index.cshtml", objIndexAssetsExpiryViewModel)); } catch (Exception ex) { string ActionName = this.ControllerContext.RouteData.Values["action"].ToString(); string ControllerName = this.ControllerContext.RouteData.Values["controller"].ToString(); string ErrorMessage = "Controler:" + ControllerName + " , Action:" + ActionName + " , Exception:" + ex.Message; _logger.LogError(ErrorMessage); return(View("~/Views/Shared/Error.cshtml", CommonFunction.HandleErrorInfo(ex, ActionName, ControllerName))); } return(new EmptyResult()); }
public IActionResult Index() { try { IndexMasterAssetsAssignmentViewModel objIndexMasterAssetsAssignmentViewModel = new IndexMasterAssetsAssignmentViewModel(); //Generate List Of Employees IEnumerable <AssetsAssignEmployeeViewModel> objAssetsAssignEmployeeViewModelList = null; string endpoint = apiBaseUrl + "MasterEmployees"; Task <string> HttpGetResponse = CommonFunction.GetWebAPI(endpoint); if (HttpGetResponse != null) { objAssetsAssignEmployeeViewModelList = JsonConvert.DeserializeObject <IEnumerable <AssetsAssignEmployeeViewModel> >(HttpGetResponse.Result).ToList(); } else { objAssetsAssignEmployeeViewModelList = Enumerable.Empty <AssetsAssignEmployeeViewModel>().ToList(); ModelState.AddModelError(string.Empty, "Server error. Please contact administrator."); } ////Generate List Of AssetsAssignment //IEnumerable<MasterAssetsAssignmentViewModel> objMasterAssetsAssignmentViewModelList = null; //endpoint = apiBaseUrl + "MasterAssetsAssignment"; //Task<string> HttpGetResponseNew = CommonFunction.GetWebAPI(endpoint); //if (HttpGetResponseNew != null) //{ // objMasterAssetsAssignmentViewModelList = JsonConvert.DeserializeObject<IEnumerable<MasterAssetsAssignmentViewModel>>(HttpGetResponse.Result).ToList(); //} //else //{ // objMasterAssetsAssignmentViewModelList = Enumerable.Empty<MasterAssetsAssignmentViewModel>().ToList(); // ModelState.AddModelError(string.Empty, "Server error. Please contact administrator."); //} objIndexMasterAssetsAssignmentViewModel.AssetsAssignEmployeeList = objAssetsAssignEmployeeViewModelList.ToList(); //############# Profile Maping ################### CPanelManager.ViewModels.Account.ValidateAccountViewModel objValidateAccountViewModel = CommonFunction.ActionResultAuthentication(HttpContext, "/MasterEmployee/Index"); if (objValidateAccountViewModel != null) { objIndexMasterAssetsAssignmentViewModel.IsSelect = objValidateAccountViewModel.IsSelect; objIndexMasterAssetsAssignmentViewModel.IsInsert = objValidateAccountViewModel.IsInsert; objIndexMasterAssetsAssignmentViewModel.IsUpdate = objValidateAccountViewModel.IsUpdate; objIndexMasterAssetsAssignmentViewModel.IsDelete = objValidateAccountViewModel.IsDelete; } //############# Profile Maping End ################### //Return View doesn't make a new requests, it just renders the view return(View("~/Views/Assets/MasterAssetsAssignment/Index.cshtml", objIndexMasterAssetsAssignmentViewModel)); } catch (Exception ex) { string ActionName = this.ControllerContext.RouteData.Values["action"].ToString(); string ControllerName = this.ControllerContext.RouteData.Values["controller"].ToString(); string ErrorMessage = "Controler:" + ControllerName + " , Action:" + ActionName + " , Exception:" + ex.Message; _logger.LogError(ErrorMessage); return(View("~/Views/Shared/Error.cshtml", CommonFunction.HandleErrorInfo(ex, ActionName, ControllerName))); } return(new EmptyResult()); }