Exemplo n.º 1
0
        public static void Save(SecModule secModule)
        {
            if (secModule.ModuleId == 0) {
                secModule.CreatedBy = Convert.ToInt32(HttpContext.Current.User.Identity.Name);
                secModule.CreatedOn = DateTime.Now;
                secModule.CreatedMachineIP = HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"].ToString();
                DbContextHelper.DbContext.Add(secModule);
            }

            secModule.UpdatedBy = Convert.ToInt32(HttpContext.Current.User.Identity.Name);
            secModule.UpdatedOn = DateTime.Now;
            secModule.UpdatedMachineIP = HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"].ToString();
            DbContextHelper.DbContext.SaveChanges();
        }
Exemplo n.º 2
0
        //int roleId
        public static List<SecModule> GetALL()
        {
            //var list = from x in DbContextHelper.DbContext.SecModules
            //           where (x.ModuleType == 0) //&& (x.Status == true)
            //           select x;

            //return list.ToList();

            var list = from sm in DbContextHelper.DbContext.SecModule
                     join srm in DbContextHelper.DbContext.SecRoleModule on new { ModuleId = sm.ModuleId } equals new { ModuleId = (Int32)srm.ModuleID } into srm_join
                     from srm in srm_join
                     //where srm.RoleID == roleId
                     select sm;
            //new
            //{
            //    ModuleId = (Int32?)sm.ModuleId,
            //    sm.ModuleName,
            //    AddPermssion = (Boolean?)srm.AddPermssion,
            //    EditPermission = (Boolean?)srm.EditPermission,
            //    DeletePermission = (Boolean?)srm.DeletePermission
            //};
            //return list.ToList();
            List<SecModule> resList = new List<SecModule>();
            SecModule su = null;
            var v = from secmodule in DbContextHelper.DbContext.SecModule
                   join secrolemodule in DbContextHelper.DbContext.SecRoleModule on new { ModuleId = secmodule.ModuleId }
                      equals new { ModuleId = (Int32)secrolemodule.ModuleID }
                      into secrolemodule_join
                   from secrolemodule in secrolemodule_join.DefaultIfEmpty()
                   select new {
                       ModuleId = (Int32?)secmodule.ModuleId,
                       secmodule.ModuleName,
                       secmodule.ModuleDesc,
                       secmodule.ParentId,
                       secmodule.Url,
                       secmodule.ModuleType,
                       secmodule.Status,
                       RoleModuleId = (Int32?)secrolemodule.RoleModuleId,
                       RoleID = (Int32?)secrolemodule.RoleID,
                       AddPermssion = (Boolean?)secrolemodule.AddPermssion,
                       EditPermission = (Boolean?)secrolemodule.EditPermission,
                       DeletePermission = (Boolean?)secrolemodule.DeletePermission
                   };

            foreach (var res in resList) {
                su = new SecModule();

                su.ModuleId = res.ModuleId;
                resList.Add(su);

                //su = new SecModule();
                //su.ModuleId = res.ModuleId;

            }

            return list.ToList();
            //from sm in db.SecModule
            //join srm in db.SecRoleModule on new { ModuleId = sm.ModuleId } equals new { ModuleId = (Int32)srm.ModuleID } into srm_join
            //from srm in srm_join.DefaultIfEmpty()
            //select new {
            //  ModuleId = (Int32?)sm.ModuleId,
            //  sm.ModuleName,
            //  AddPermssion = (Boolean?)srm.AddPermssion,
            //  EditPermission = (Boolean?)srm.EditPermission,
            //  DeletePermission = (Boolean?)srm.DeletePermission
            //}
        }
Exemplo n.º 3
0
 public static void Delete(SecModule module)
 {
     DbContextHelper.DbContext.DeleteObject(module);
 }