public static List <secRoleModuleGet> getRolePermission(int roleID)
        {
            List <secRoleModuleGet> resRoleModule       = new List <secRoleModuleGet>();
            secRoleModuleGet        objsecRoleModuleGet = null;

            var resList = from sm in DbContextHelper.DbContext.SecModule
                          join srm in DbContextHelper.DbContext.SecRoleModule
                          on new { sm.ModuleId, RoleID = roleID, SecroleModStatus = 1 }
            equals new { ModuleId = (Int32)srm.ModuleID, srm.RoleID, SecroleModStatus = (Int32)srm.Status }
            //where sm.Status == true
            //
            select new {
                ModuleId = (Int32?)sm.ModuleId,
                sm.ModuleName,
                sm.ModuleDesc,
                sm.ParentId,
                sm.Url,
                sm.ModuleType,
                SecModuleStatus  = sm.Status,
                RoleModuleId     = (Int32?)srm.RoleModuleId,
                RoleID           = (Int32?)srm.RoleID,
                ViewPermission   = (Boolean?)srm.ViewPermission,
                AddPermssion     = (Boolean?)srm.AddPermssion,
                EditPermission   = (Boolean?)srm.EditPermission,
                DeletePermission = (Boolean?)srm.DeletePermission,
                SecRoleModStatus = (Int32?)srm.Status
            };

            foreach (var get in resList)
            {
                objsecRoleModuleGet = new secRoleModuleGet();

                objsecRoleModuleGet.ModuleId   = (int?)get.ModuleId;
                objsecRoleModuleGet.ModuleName = get.ModuleName;
                objsecRoleModuleGet.ParentId   = (int?)get.ParentId;

                objsecRoleModuleGet.Url              = get.Url;
                objsecRoleModuleGet.ModuleType       = get.ModuleType;
                objsecRoleModuleGet.RoleModuleId     = (int?)get.RoleModuleId;
                objsecRoleModuleGet.RoleID           = (int?)get.RoleID;
                objsecRoleModuleGet.ViewPermssion    = (Boolean?)get.ViewPermission;
                objsecRoleModuleGet.AddPermssion     = (Boolean?)get.AddPermssion;
                objsecRoleModuleGet.EditPermission   = (Boolean?)get.EditPermission;
                objsecRoleModuleGet.DeletePermission = (Boolean?)get.DeletePermission;
                objsecRoleModuleGet.RoleModuleStatus = (Int32?)get.SecRoleModStatus;

                resRoleModule.Add(objsecRoleModuleGet);
            }

            return(resRoleModule);
        }
        /// <summary>
        /// This is used to prime database
        /// </summary>
        /// <param name="roleID"></param>
        /// <returns></returns>
        public static List<secRoleModuleGet> primeRoleModule(int roleID)
        {
            List<secRoleModuleGet> resRoleModule = new List<secRoleModuleGet>();
            secRoleModuleGet objsecRoleModuleGet = null;

            var resList = from secmodule in DbContextHelper.DbContext.SecModule
                        //join secrolemodule in DbContextHelper.DbContext.SecRoleModules
                        //	 on new { secmodule.ModuleId, RoleID = roleID, SecroleModStatus = 1 }
                        //	 equals new { ModuleId = (Int32)secrolemodule.ModuleID, secrolemodule.RoleID, SecroleModStatus = (Int32)secrolemodule.Status } into secrolemodule_join
                        //from secrolemodule in secrolemodule_join.DefaultIfEmpty()
                        where secmodule.Status == true
                        select new {
                            ModuleId = (Int32?)secmodule.ModuleId,
                            secmodule.ModuleName,
                            secmodule.ModuleDesc,
                            secmodule.ParentId,
                            secmodule.Url,
                            secmodule.ModuleType,
                            SecModuleStatus = secmodule.Status,
                            //RoleModuleId = (Int32?)secrolemodule.RoleModuleId,
                            RoleID = roleID,
                            ViewPermission = false,
                            AddPermssion = false,
                            EditPermission = false,
                            DeletePermission = false,
                            SecRoleModStatus = 1, //(Int32?)secrolemodule.Status,

                            /*added by asutosh*/
                            HasNew = false,
                            HasEdit = false,
                            HasDelete = false,

                            SortOrder = secmodule.SortOrder,
                        };

            foreach (var get in resList) {
                objsecRoleModuleGet = new secRoleModuleGet();

                objsecRoleModuleGet.ModuleId = (int?)get.ModuleId;
                objsecRoleModuleGet.ModuleName = get.ModuleName;
                objsecRoleModuleGet.ParentId = (int?)get.ParentId;
                objsecRoleModuleGet.Url = get.Url;
                objsecRoleModuleGet.ModuleType = get.ModuleType;
                //objsecRoleModuleGet.RoleModuleId = (int?)get.RoleModuleId;
                objsecRoleModuleGet.RoleID = (int?)get.RoleID;
                objsecRoleModuleGet.ViewPermssion = get.ViewPermission;
                objsecRoleModuleGet.AddPermssion = get.AddPermssion;
                objsecRoleModuleGet.EditPermission = get.EditPermission;
                objsecRoleModuleGet.DeletePermission = get.DeletePermission;
                objsecRoleModuleGet.RoleModuleStatus = (Int32?)get.SecRoleModStatus;

                objsecRoleModuleGet.HasNew = get.HasNew;
                objsecRoleModuleGet.HasEdit = get.HasEdit;
                objsecRoleModuleGet.HasDelete = get.HasDelete;

                objsecRoleModuleGet.SortOrder = get.SortOrder ?? 0;
                //objsecRoleModuleGet.ClientID = get.ClientID ?? 0;

                resRoleModule.Add(objsecRoleModuleGet);
            }

            return resRoleModule;
            //return resList.ToList();
        }
        public static List<secRoleModuleGet> getRolePermission(int roleID)
        {
            List<secRoleModuleGet> resRoleModule = new List<secRoleModuleGet>();
            secRoleModuleGet objsecRoleModuleGet = null;

            var resList = from sm in DbContextHelper.DbContext.SecModule
                        join srm in DbContextHelper.DbContext.SecRoleModule
                            on new { sm.ModuleId, RoleID = roleID, SecroleModStatus = 1 }
                         equals new { ModuleId = (Int32)srm.ModuleID, srm.RoleID, SecroleModStatus = (Int32)srm.Status }
                        //where sm.Status == true
                        //
                        select new {
                            ModuleId = (Int32?)sm.ModuleId,
                            sm.ModuleName,
                            sm.ModuleDesc,
                            sm.ParentId,
                            sm.Url,
                            sm.ModuleType,
                            SecModuleStatus = sm.Status,
                            RoleModuleId = (Int32?)srm.RoleModuleId,
                            RoleID = (Int32?)srm.RoleID,
                            ViewPermission = (Boolean?)srm.ViewPermission,
                            AddPermssion = (Boolean?)srm.AddPermssion,
                            EditPermission = (Boolean?)srm.EditPermission,
                            DeletePermission = (Boolean?)srm.DeletePermission,
                            SecRoleModStatus = (Int32?)srm.Status
                        };

            foreach (var get in resList) {
                objsecRoleModuleGet = new secRoleModuleGet();

                objsecRoleModuleGet.ModuleId = (int?)get.ModuleId;
                objsecRoleModuleGet.ModuleName = get.ModuleName;
                objsecRoleModuleGet.ParentId = (int?)get.ParentId;

                objsecRoleModuleGet.Url = get.Url;
                objsecRoleModuleGet.ModuleType = get.ModuleType;
                objsecRoleModuleGet.RoleModuleId = (int?)get.RoleModuleId;
                objsecRoleModuleGet.RoleID = (int?)get.RoleID;
                objsecRoleModuleGet.ViewPermssion = (Boolean?)get.ViewPermission;
                objsecRoleModuleGet.AddPermssion = (Boolean?)get.AddPermssion;
                objsecRoleModuleGet.EditPermission = (Boolean?)get.EditPermission;
                objsecRoleModuleGet.DeletePermission = (Boolean?)get.DeletePermission;
                objsecRoleModuleGet.RoleModuleStatus = (Int32?)get.SecRoleModStatus;

                resRoleModule.Add(objsecRoleModuleGet);
            }

            return resRoleModule;
        }
        public static List<secRoleModuleGet> getRoleModule(int clientID, int roleID)
        {
            List<secRoleModuleGet> resRoleModule = new List<secRoleModuleGet>();
            secRoleModuleGet objsecRoleModuleGet = null;

            var resList = from secmodule in DbContextHelper.DbContext.SecModule
                        join secrolemodule in DbContextHelper.DbContext.SecRoleModule
                            on new {
                                secmodule.ModuleId,
                                RoleID = roleID,
                                SecroleModStatus = 1,
                                ClientID = (int)clientID
                            }
                            equals new {
                                ModuleId = (Int32)secrolemodule.ModuleID,
                                secrolemodule.RoleID,
                                SecroleModStatus = (Int32)secrolemodule.Status,
                                ClientID = (int)secrolemodule.ClientID
                            } into secrolemodule_join
                        from secrolemodule in secrolemodule_join.DefaultIfEmpty()
                        where secmodule.Status == true && secmodule.IsSystem == false
                        select new {
                            ModuleId = (Int32?)secmodule.ModuleId,
                            secmodule.ModuleName,
                            secmodule.ModuleDesc,
                            secmodule.ParentId,
                            secmodule.Url,
                            secmodule.ModuleType,
                            SecModuleStatus = secmodule.Status,
                            RoleModuleId = (Int32?)secrolemodule.RoleModuleId,
                            RoleID = (Int32?)secrolemodule.RoleID,
                            ViewPermission = (Boolean?)secrolemodule.ViewPermission,
                            AddPermssion = (Boolean?)secrolemodule.AddPermssion,
                            EditPermission = (Boolean?)secrolemodule.EditPermission,
                            DeletePermission = (Boolean?)secrolemodule.DeletePermission,
                            SecRoleModStatus = (Int32?)secrolemodule.Status,

                            /*added by asutosh*/
                            HasNew = (Boolean?)secmodule.HasNew,
                            HasEdit = (Boolean?)secmodule.HasEdit,
                            HasDelete = (Boolean?)secmodule.HasDelete,

                            SortOrder = secmodule.SortOrder,
                            ClientID = secrolemodule.ClientID

                        };

            foreach (var get in resList) {
                objsecRoleModuleGet = new secRoleModuleGet();

                objsecRoleModuleGet.ModuleId = (int?)get.ModuleId;
                objsecRoleModuleGet.ModuleName = get.ModuleName;
                objsecRoleModuleGet.ParentId = (int?)get.ParentId;
                objsecRoleModuleGet.Url = get.Url;
                objsecRoleModuleGet.ModuleType = get.ModuleType;
                objsecRoleModuleGet.RoleModuleId = (int?)get.RoleModuleId;
                objsecRoleModuleGet.RoleID = (int?)get.RoleID;
                objsecRoleModuleGet.ViewPermssion = get.ViewPermission ?? false;
                objsecRoleModuleGet.AddPermssion = get.AddPermssion ?? false;
                objsecRoleModuleGet.EditPermission = get.EditPermission ?? false;
                objsecRoleModuleGet.DeletePermission = get.DeletePermission ?? false;
                objsecRoleModuleGet.RoleModuleStatus = (Int32?)get.SecRoleModStatus;

                objsecRoleModuleGet.HasNew = get.HasNew ?? false;
                objsecRoleModuleGet.HasEdit = get.HasEdit ?? false;
                objsecRoleModuleGet.HasDelete = get.HasDelete ?? false;

                objsecRoleModuleGet.SortOrder = get.SortOrder ?? 0;
                objsecRoleModuleGet.ClientID = get.ClientID ?? 0;

                resRoleModule.Add(objsecRoleModuleGet);
            }

            return resRoleModule;
            //return resList.ToList();
        }
        /// <summary>
        /// This is used to prime database
        /// </summary>
        /// <param name="roleID"></param>
        /// <returns></returns>
        public static List <secRoleModuleGet> primeRoleModule(int roleID)
        {
            List <secRoleModuleGet> resRoleModule       = new List <secRoleModuleGet>();
            secRoleModuleGet        objsecRoleModuleGet = null;

            var resList = from secmodule in DbContextHelper.DbContext.SecModule
                          //join secrolemodule in DbContextHelper.DbContext.SecRoleModules
                          //	 on new { secmodule.ModuleId, RoleID = roleID, SecroleModStatus = 1 }
                          //	 equals new { ModuleId = (Int32)secrolemodule.ModuleID, secrolemodule.RoleID, SecroleModStatus = (Int32)secrolemodule.Status } into secrolemodule_join
                          //from secrolemodule in secrolemodule_join.DefaultIfEmpty()
                          where secmodule.Status == true
                          select new {
                ModuleId = (Int32?)secmodule.ModuleId,
                secmodule.ModuleName,
                secmodule.ModuleDesc,
                secmodule.ParentId,
                secmodule.Url,
                secmodule.ModuleType,
                SecModuleStatus = secmodule.Status,
                //RoleModuleId = (Int32?)secrolemodule.RoleModuleId,
                RoleID           = roleID,
                ViewPermission   = false,
                AddPermssion     = false,
                EditPermission   = false,
                DeletePermission = false,
                SecRoleModStatus = 1,                                     //(Int32?)secrolemodule.Status,

                /*added by asutosh*/
                HasNew    = false,
                HasEdit   = false,
                HasDelete = false,

                SortOrder = secmodule.SortOrder,
            };

            foreach (var get in resList)
            {
                objsecRoleModuleGet = new secRoleModuleGet();

                objsecRoleModuleGet.ModuleId   = (int?)get.ModuleId;
                objsecRoleModuleGet.ModuleName = get.ModuleName;
                objsecRoleModuleGet.ParentId   = (int?)get.ParentId;
                objsecRoleModuleGet.Url        = get.Url;
                objsecRoleModuleGet.ModuleType = get.ModuleType;
                //objsecRoleModuleGet.RoleModuleId = (int?)get.RoleModuleId;
                objsecRoleModuleGet.RoleID           = (int?)get.RoleID;
                objsecRoleModuleGet.ViewPermssion    = get.ViewPermission;
                objsecRoleModuleGet.AddPermssion     = get.AddPermssion;
                objsecRoleModuleGet.EditPermission   = get.EditPermission;
                objsecRoleModuleGet.DeletePermission = get.DeletePermission;
                objsecRoleModuleGet.RoleModuleStatus = (Int32?)get.SecRoleModStatus;

                objsecRoleModuleGet.HasNew    = get.HasNew;
                objsecRoleModuleGet.HasEdit   = get.HasEdit;
                objsecRoleModuleGet.HasDelete = get.HasDelete;

                objsecRoleModuleGet.SortOrder = get.SortOrder ?? 0;
                //objsecRoleModuleGet.ClientID = get.ClientID ?? 0;

                resRoleModule.Add(objsecRoleModuleGet);
            }

            return(resRoleModule);
            //return resList.ToList();
        }
        public static List <secRoleModuleGet> getRoleModule(int clientID, int roleID)
        {
            List <secRoleModuleGet> resRoleModule       = new List <secRoleModuleGet>();
            secRoleModuleGet        objsecRoleModuleGet = null;

            var resList = from secmodule in DbContextHelper.DbContext.SecModule
                          join secrolemodule in DbContextHelper.DbContext.SecRoleModule
                          on new {
                secmodule.ModuleId,
                RoleID           = roleID,
                SecroleModStatus = 1,
                ClientID         = (int)clientID
            }
            equals new {
                ModuleId = (Int32)secrolemodule.ModuleID,
                secrolemodule.RoleID,
                SecroleModStatus = (Int32)secrolemodule.Status,
                ClientID         = (int)secrolemodule.ClientID
            } into secrolemodule_join
            from secrolemodule in secrolemodule_join.DefaultIfEmpty()
            where secmodule.Status == true && secmodule.IsSystem == false
                select new {
                ModuleId = (Int32?)secmodule.ModuleId,
                secmodule.ModuleName,
                secmodule.ModuleDesc,
                secmodule.ParentId,
                secmodule.Url,
                secmodule.ModuleType,
                SecModuleStatus  = secmodule.Status,
                RoleModuleId     = (Int32?)secrolemodule.RoleModuleId,
                RoleID           = (Int32?)secrolemodule.RoleID,
                ViewPermission   = (Boolean?)secrolemodule.ViewPermission,
                AddPermssion     = (Boolean?)secrolemodule.AddPermssion,
                EditPermission   = (Boolean?)secrolemodule.EditPermission,
                DeletePermission = (Boolean?)secrolemodule.DeletePermission,
                SecRoleModStatus = (Int32?)secrolemodule.Status,

                /*added by asutosh*/
                HasNew    = (Boolean?)secmodule.HasNew,
                HasEdit   = (Boolean?)secmodule.HasEdit,
                HasDelete = (Boolean?)secmodule.HasDelete,

                SortOrder = secmodule.SortOrder,
                ClientID  = secrolemodule.ClientID
            };

            foreach (var get in resList)
            {
                objsecRoleModuleGet = new secRoleModuleGet();

                objsecRoleModuleGet.ModuleId         = (int?)get.ModuleId;
                objsecRoleModuleGet.ModuleName       = get.ModuleName;
                objsecRoleModuleGet.ParentId         = (int?)get.ParentId;
                objsecRoleModuleGet.Url              = get.Url;
                objsecRoleModuleGet.ModuleType       = get.ModuleType;
                objsecRoleModuleGet.RoleModuleId     = (int?)get.RoleModuleId;
                objsecRoleModuleGet.RoleID           = (int?)get.RoleID;
                objsecRoleModuleGet.ViewPermssion    = get.ViewPermission ?? false;
                objsecRoleModuleGet.AddPermssion     = get.AddPermssion ?? false;
                objsecRoleModuleGet.EditPermission   = get.EditPermission ?? false;
                objsecRoleModuleGet.DeletePermission = get.DeletePermission ?? false;
                objsecRoleModuleGet.RoleModuleStatus = (Int32?)get.SecRoleModStatus;

                objsecRoleModuleGet.HasNew    = get.HasNew ?? false;
                objsecRoleModuleGet.HasEdit   = get.HasEdit ?? false;
                objsecRoleModuleGet.HasDelete = get.HasDelete ?? false;

                objsecRoleModuleGet.SortOrder = get.SortOrder ?? 0;
                objsecRoleModuleGet.ClientID  = get.ClientID ?? 0;

                resRoleModule.Add(objsecRoleModuleGet);
            }

            return(resRoleModule);
            //return resList.ToList();
        }