public ActionResult CheckIsProfileImageExists() { try { var result = _iProfile.IsProfileImageExists(Convert.ToInt64(_sessionHandler.UserId)); if (result) { string cacheProfileKey = Convert.ToString(_sessionHandler.CacheProfileKey); string tempimageBase64String; if (!CacheHelper.CheckExists(cacheProfileKey)) { var imageBase64String = _iProfile.GetProfileImageBase64String(Convert.ToInt64(_sessionHandler.UserId)); tempimageBase64String = string.Concat("data:image/png;base64,", imageBase64String); CacheHelper.AddToCacheWithNoExpiration(cacheProfileKey, tempimageBase64String); } else { tempimageBase64String = (string)CacheHelper.GetStoreCachebyKey(cacheProfileKey); } return(Json(new { result = true, base64string = tempimageBase64String }, JsonRequestBehavior.AllowGet)); } else { return(Json(new { result = false, base64string = "" }, JsonRequestBehavior.AllowGet)); } } catch (Exception) { throw; } }
public List <MenuCategoryCacheViewModel> ShowCategories(int roleId) { List <MenuCategoryCacheViewModel> renderCategoriesList; var key = $"MenuCategory_Cache_{roleId}"; if (!CacheHelper.CheckExists(key)) { using (var db = new DatabaseContext()) { var data = (from cat in db.MenuCategory orderby cat.SortingOrder where cat.Status == true && cat.RoleId == roleId select new MenuCategoryCacheViewModel() { MenuCategoryName = cat.MenuCategoryName, MenuCategoryId = cat.MenuCategoryId }).ToList(); CacheHelper.AddToCacheWithNoExpiration(key, data); return(data); } } else { renderCategoriesList = (List <MenuCategoryCacheViewModel>)CacheHelper.GetStoreCachebyKey(key); } return(renderCategoriesList); }
public List <SelectListItem> KnowledgebaseTypeList() { try { List <SelectListItem> knowledgebaseTypeList; string key = "KnowledgebaseType_Cache"; if (!CacheHelper.CheckExists(key)) { using (SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["DatabaseConnection"].ConnectionString)) { con.Open(); knowledgebaseTypeList = con.Query <SelectListItem>("Usp_GetKnowledgebaseType", null, null, false, 0, CommandType.StoredProcedure).ToList(); knowledgebaseTypeList.Insert(0, new SelectListItem() { Value = "", Text = "-----Select-----" }); } CacheHelper.AddToCacheWithNoExpiration(key, knowledgebaseTypeList); } else { knowledgebaseTypeList = (List <SelectListItem>)CacheHelper.GetStoreCachebyKey(key); } return(knowledgebaseTypeList); } catch (Exception) { throw; } }
public List <SelectListItem> GetAllActiveCategoryforListbox() { try { List <SelectListItem> categoryList; string key = "Category_CacheListbox"; if (!CacheHelper.CheckExists(key)) { categoryList = (from cat in _context.Category where cat.Status == true select new SelectListItem() { Text = cat.CategoryName, Value = cat.CategoryId.ToString() }).ToList(); CacheHelper.AddToCacheWithNoExpiration(key, categoryList); } else { categoryList = (List <SelectListItem>)CacheHelper.GetStoreCachebyKey(key); } return(categoryList); } catch (Exception) { throw; } }
public static List<SubMenuMasterViewModel> ShowSubMenu(int roleId, int categoryId, int menuid) { List<SubMenuMasterViewModel> renderSubMenuList; var key = $"SubMenu_Cache_{roleId}_{categoryId}_{menuid}"; if (!CacheHelper.CheckExists(key)) { using (var db = new DatabaseContext()) { var data = (from submenu in db.SubMenuMasters where submenu.Status == true && submenu.RoleId == roleId && submenu.CategoryId == categoryId && submenu.MenuId == menuid select new SubMenuMasterViewModel() { SubMenuName = submenu.SubMenuName, ControllerName = submenu.ControllerName, ActionMethod = submenu.ActionMethod, SubMenuId = submenu.SubMenuId }).ToList(); CacheHelper.AddToCacheWithNoExpiration(key, data); return data; } } else { renderSubMenuList = (List<SubMenuMasterViewModel>)CacheHelper.GetStoreCachebyKey(key); } return renderSubMenuList; }
public static List<MenuMasterCacheViewModel> ShowMenu(int roleId, int categoryId) { List<MenuMasterCacheViewModel> renderCategoriesList; string key = $"MainMenu_Cache_{roleId}_{categoryId}"; if (!CacheHelper.CheckExists(key)) { using (var db = new DatabaseContext()) { var data = (from menu in db.MenuMaster where menu.Status == true && menu.RoleId == roleId && menu.CategoryId == categoryId select new MenuMasterCacheViewModel() { MenuName = menu.MenuName, ControllerName = menu.ControllerName, ActionMethod = menu.ActionMethod, MenuId = menu.MenuId }).ToList(); CacheHelper.AddToCacheWithNoExpiration(key, data); return data; } } else { renderCategoriesList = (List<MenuMasterCacheViewModel>)CacheHelper.GetStoreCachebyKey(key); } return renderCategoriesList; }
public List <SelectListItem> GetAllActiveRoles() { try { string key = "Role_Cache"; List <SelectListItem> listofActiveMenu; if (!CacheHelper.CheckExists(key)) { listofActiveMenu = (from roleMaster in _context.RoleMasters where roleMaster.Status == true select new SelectListItem { Value = roleMaster.RoleId.ToString(), Text = roleMaster.RoleName }).ToList(); listofActiveMenu.Insert(0, new SelectListItem() { Value = "", Text = "---Select Role---" }); CacheHelper.AddToCacheWithNoExpiration(key, listofActiveMenu); } else { listofActiveMenu = (List <SelectListItem>)CacheHelper.GetStoreCachebyKey(key); } return(listofActiveMenu); } catch (Exception) { throw; } }
public List <SelectListItem> GetAllStatusWithoutOverdueandEscalationSelectListItem() { try { List <SelectListItem> statusList; string key = "CommonStatus_Cache"; if (!CacheHelper.CheckExists(key)) { statusList = (from status in _context.Status where status.IsInternalStatus == false select new SelectListItem() { Text = status.StatusText, Value = status.StatusId.ToString() }).ToList(); statusList.Insert(0, new SelectListItem() { Value = "", Text = "-----Select-----" }); CacheHelper.AddToCacheWithNoExpiration(key, statusList); } else { statusList = (List <SelectListItem>)CacheHelper.GetStoreCachebyKey(key); } return(statusList); } catch (Exception) { throw; } }
private void AssignSessionValues(Usermaster usermasterModel, SavedAssignedRolesViewModel rolesModel) { var sessionHandler = new SessionHandler { UserId = Convert.ToString(usermasterModel.UserId), UserName = usermasterModel.FirstName + " " + usermasterModel.LastName, EmailId = usermasterModel.EmailId, RoleId = Convert.ToString(rolesModel.RoleId), RoleName = Convert.ToString(rolesModel.RoleName), CacheProfileKey = "Cache_" + usermasterModel.UserId }; if (rolesModel.RoleId == Convert.ToInt32(StatusMain.Roles.AgentAdmin)) { sessionHandler.AgentAdminCategoryId = Convert.ToString(_category.GetAdminCategory(usermasterModel.UserId)); } if (rolesModel.RoleId == Convert.ToInt32(StatusMain.Roles.Hod)) { sessionHandler.HodCategoryId = Convert.ToString(_category.GetHodCategory(usermasterModel.UserId)); } var result = _iProfile.IsProfileImageExists(Convert.ToInt64(sessionHandler.UserId)); if (result) { string cacheProfileKey = Convert.ToString(sessionHandler.CacheProfileKey); if (!CacheHelper.CheckExists(cacheProfileKey)) { var imageBase64String = _iProfile.GetProfileImageBase64String(Convert.ToInt64(sessionHandler.UserId)); var tempimageBase64String = string.Concat("data:image/png;base64,", imageBase64String); CacheHelper.AddToCacheWithNoExpiration(cacheProfileKey, tempimageBase64String); } } }
public List <SelectListItem> GetAllPrioritySelectListItem() { try { List <SelectListItem> priorityList; string key = "Priority_Cache"; if (!CacheHelper.CheckExists(key)) { priorityList = (from priority in _context.Priority select new SelectListItem() { Text = priority.PriorityName, Value = priority.PriorityId.ToString() }).ToList(); priorityList.Insert(0, new SelectListItem() { Value = "", Text = "-----Select-----" }); CacheHelper.AddToCacheWithNoExpiration(key, priorityList); } else { priorityList = (List <SelectListItem>)CacheHelper.GetStoreCachebyKey(key); } return(priorityList); } catch (Exception) { throw; } }