Пример #1
0
 public int Create(RPT_Role data, List <RPT_UserRolePriv> list)
 {
     using (ReportEntities db = new ReportEntities())
     {
         db.RPT_Role.Add(data);
         foreach (RPT_UserRolePriv userRole in list)
         {
             db.RPT_UserRolePriv.Add(userRole);
         }
         return(db.SaveChanges());
     }
 }
Пример #2
0
 public int Update(RPT_Role data, List <RPT_UserRolePriv> list)
 {
     using (ReportEntities db = new ReportEntities())
     {
         var item = db.RPT_Role.FirstOrDefault(p => p.RoleCode == data.RoleCode);
         if (item != null)
         {
             item.RoleName = data.RoleName;
             item.IsActive = data.IsActive;
             item.RoleDesc = data.RoleDesc;
         }
         var items = db.RPT_UserRolePriv.Where(p => p.UserRoleCode == data.RoleCode);
         foreach (var v in items)
         {
             db.RPT_UserRolePriv.Remove(v);
         }
         foreach (RPT_UserRolePriv userRole in list)
         {
             db.RPT_UserRolePriv.Add(userRole);
         }
         return(db.SaveChanges());
     }
 }