public override void OnActionExecuting(ActionExecutingContext filterContext) { HomeLayOutModel objHomeLayOutModel = new HomeLayOutModel(); if (filterContext.HttpContext.Session["LayOutData"] != null) { objHomeLayOutModel = (HomeLayOutModel)filterContext.HttpContext.Session["LayOutData"]; } else { serviceResponse = objUtilityWeb.GetAsync(WebApiURL.Home + "/GetLayOutData"); objHomeLayOutModel = serviceResponse.StatusCode == HttpStatusCode.OK ? serviceResponse.Content.ReadAsAsync <HomeLayOutModel>().Result : null; filterContext.HttpContext.Session["LayOutData"] = objHomeLayOutModel; } base.OnActionExecuting(filterContext); }
public ActionResult Index() { HomeLayOutModel objHomeLayOutModel = (HomeLayOutModel)Session["LayOutData"]; HomeDocumentViewModel homeDocumentViewModel = new HomeDocumentViewModel(); homeDocumentViewModel.objListSubCategory = new List <SubCategoryModel>(); homeDocumentViewModel.objListDocumentService = new List <DocumentModel>(); List <PackedDocumentsParent> lstPackedDocumentsParent = new List <PackedDocumentsParent>(); serviceResponse = objUtilityWeb.GetAsync(WebApiURL.Home + "/GetCategoryList?CategoryId=" + objHomeLayOutModel.objViewCategoryModel.CategoryList[0].CategoryID.ToString()); var objHomeCategoryViewModel = serviceResponse.StatusCode == HttpStatusCode.OK ? serviceResponse.Content.ReadAsAsync <HomeCategoryViewModel>().Result : null; foreach (var subcategory in objHomeCategoryViewModel.objListSubCategory) { serviceResponse = objUtilityWeb.GetAsync(WebApiURL.Home + "/GetSubCategoryList?SubCategoryId=" + subcategory.SubCategoryID.ToString()); objHomeCategoryViewModel = serviceResponse.StatusCode == HttpStatusCode.OK ? serviceResponse.Content.ReadAsAsync <HomeCategoryViewModel>().Result : null; homeDocumentViewModel.objListSubCategory.Add(subcategory); homeDocumentViewModel.objListDocumentService.AddRange(objHomeCategoryViewModel.objListDocumentModel); foreach (var packedDocument in objHomeCategoryViewModel.objListDocumentModel) { serviceResponse = objUtilityWeb.GetAsync(WebApiURL.Home + "/GetDocumentList?DocumentId=" + packedDocument.DocumentID.ToString()); var objHomeDocumentViewModel = serviceResponse.StatusCode == HttpStatusCode.OK ? serviceResponse.Content.ReadAsAsync <HomeDocumentViewModel>().Result : null; if (objHomeDocumentViewModel.objListDocumentService.Count > 1) { lstPackedDocumentsParent.Add(new PackedDocumentsParent { SubCategoryID = packedDocument.SubCategoryID, DocumentTitle = packedDocument.DocumentTitle, DocumentDescription = packedDocument.DocumentDescription }); } } } Session["PackedDocument"] = lstPackedDocumentsParent; //serviceResponse = objUtilityWeb.GetAsync(WebApiURL.Home + "/GetSubCategoryList?SubCategoryId=" + SubCategoryId.ToString()); //objHomeCategoryViewModel = serviceResponse.StatusCode == HttpStatusCode.OK ? serviceResponse.Content.ReadAsAsync<HomeCategoryViewModel>().Result : null; //objHomeCategoryViewModel.SelectedSubCatId = SubCategoryId; ViewBag.Message = "Modify this template to jump-start your ASP.NET MVC application."; return(View(homeDocumentViewModel)); }
public HomeLayOutModel GetLayOutData() { HomeLayOutModel objHomeLayOutModel = new HomeLayOutModel(); BLCategory objBLCategory = new BLCategory(); BLDocument objBLDocument = new BLDocument(); BLSubCategory objBLSubCategory = new BLSubCategory(); ViewCategoryModel objViewCategoryModel = new ViewCategoryModel(); objViewCategoryModel.CurrentPage = 1; objViewCategoryModel.PageSize = int.MaxValue - 1; objHomeLayOutModel.objViewCategoryModel = new ViewCategoryModel(); objHomeLayOutModel.objViewCategoryModel = objBLCategory.GetCategoryList(objViewCategoryModel); if (objHomeLayOutModel != null && objHomeLayOutModel.objViewCategoryModel != null && objHomeLayOutModel.objViewCategoryModel.CategoryList != null && objHomeLayOutModel.objViewCategoryModel.CategoryList.Count > 0) { for (int i = 0; i < objHomeLayOutModel.objViewCategoryModel.CategoryList.Count; i++) { //string[] DocumentIds = objHomeLayOutModel.objViewCategoryModel.CategoryList[i].QuickLinks.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries); //if (DocumentIds != null && DocumentIds.Length > 0) //{ // objHomeLayOutModel.objViewCategoryModel.CategoryList[i].objDocumentList = new List<DocumentModel>(); // for (int j = 0; j < DocumentIds.Length; j++) // { // objHomeLayOutModel.objViewCategoryModel.CategoryList[i].objDocumentList.Add(objBLDocument.GetDocumentById(Convert.ToInt32(DocumentIds[j]))); // } //} } } ViewSubCategoryModel objViewSubCategoryModel = new ViewSubCategoryModel(); objViewSubCategoryModel.CurrentPage = 1; objViewSubCategoryModel.PageSize = int.MaxValue - 1; objHomeLayOutModel.objSubViewCategoryModel = new ViewSubCategoryModel(); objHomeLayOutModel.objSubViewCategoryModel = objBLSubCategory.GetSubCategoryList(objViewSubCategoryModel); return(objHomeLayOutModel); }