コード例 #1
0
ファイル: Repository.cs プロジェクト: antcorpinc/Coke2Home
 public virtual void Delete(TEntity entityToDelete)
 {
     if (context.Entry(entityToDelete).State == EntityState.Detached)
     {
         dbSet.Attach(entityToDelete);
     }
     dbSet.Remove(entityToDelete);
     this.Save();
 }
コード例 #2
0
ファイル: UserController.cs プロジェクト: antcorpinc/Dew
        private List <Models.RolePrivilege> GetRelatedPrivilegesForRoleAndApp(Guid roleId, Guid appId)
        {
            List <Models.RolePrivilege> rolePrivileges = new List <Models.RolePrivilege>();
            var role = _context.Role.Where(r => r.Id == roleId).FirstOrDefault();

            rolePrivileges = _context.Entry(role).Collection(r => r.FeatureTypeRolePrivilege).Query()
                             .Join(_context.ApplicationFeature, ftp => ftp.FeatureTypeId, ap => ap.FeatureTypeId, (r, ftp) => new { r, ftp })
                             .Where(a => a.ftp.ApplicationId == appId)
                             .Select(m => new Models.RolePrivilege
            {
                FeatureTypeId   = m.ftp.FeatureTypeId,
                Privileges      = m.r.Privileges,
                RoleName        = m.r.Role.Name,
                FeatureTypeName = m.ftp.FeatureType.Name,
                FeatureLabel    = m.ftp.FeatureType.Description,
                ParentFeatureId = m.ftp.FeatureType.ParentFeatureId,
                Order           = m.ftp.FeatureType.Order,
                ApplicationName = m.ftp.Application.Name
            }).OrderBy(rp => rp.ParentFeatureId).ThenBy(p => p.Order).ToList();
            return(rolePrivileges);
        }