/// <summary> /// Set session variables /// </summary> private void SetSessionVariables() { Expression <Func <Menu, bool> > where = m => m.ParentID == null; Expression <Func <Menu, object> >[] include = { m => m.SubMenus }; IEnumerable <MenuViewModel> menus = mapper.Map <IEnumerable <MenuViewModel> > (menuService.FindAll(where, include)); IEnumerable <NotificationTypeViewModel> notificationTypes = mapper.Map <IEnumerable <NotificationTypeViewModel> > (ntService.FindAll()); IEnumerable <NotificationCategoryViewModel> notificationCategories = mapper.Map <IEnumerable <NotificationCategoryViewModel> >(ncService.FindAll()); IEnumerable <DeviceTypeViewModel> deviceTypes = mapper.Map <IEnumerable <DeviceTypeViewModel> >(dtService.FindAll()); HttpContext.Session.SetString("SideMenus", JsonConvert.SerializeObject(menus, Formatting.Indented, new JsonSerializerSettings { ReferenceLoopHandling = ReferenceLoopHandling.Ignore })); HttpContext.Session.SetString("NotificationTypes", JsonConvert.SerializeObject(notificationTypes, Formatting.Indented, new JsonSerializerSettings { ReferenceLoopHandling = ReferenceLoopHandling.Ignore })); HttpContext.Session.SetString("NotificationCategories", JsonConvert.SerializeObject(notificationCategories, Formatting.Indented, new JsonSerializerSettings { ReferenceLoopHandling = ReferenceLoopHandling.Ignore })); HttpContext.Session.SetString("DeviceTypes", JsonConvert.SerializeObject(deviceTypes, Formatting.Indented, new JsonSerializerSettings { ReferenceLoopHandling = ReferenceLoopHandling.Ignore })); }