Exemplo n.º 1
0
 public static void DepotAdd(this DepotEntities db, string name, Guid campusId, Guid userId, int ordinal, string defaultObjectView, string defaultObjectType, string objectTypes)
 {
     var depot = new Depot
     {
         Id = db.GlobalId(),
         Name = name,
         CampusId = campusId,
         Ordinal = ordinal,
         DefaultObjectView = defaultObjectView[0].ToString(),
         DefaultObjectType = defaultObjectType[0].ToString(),
         ObjectTypes = objectTypes,
         Type = DepotType.通用库,
         State = State.启用
     };
     db.Depot.Add(depot);
     var depotRole = new DepotRole
     {
         Id = db.GlobalId(),
         DepotId = depot.Id,
         Name = "{0}管理组".Formatted(name),
         Rights = "*",
         Ordinal = 0,
         State = State.内置
     };
     db.DepotRole.Add(depotRole);
     var depotUserRole = new DepotUserRole
     {
         UserId = userId,
         DepotRoleId = depotRole.Id
     };
     db.DepotUserRole.Add(depotUserRole);
     db.SaveChanges();
 }
Exemplo n.º 2
0
 protected void search_Search(object sender, Telerik.Web.UI.SearchBoxEventArgs e)
 {
     if (CurrentNode.HasValue && !e.Value.None())
     {
         var id = CurrentNode.Value;
         var userRole = new DepotUserRole
         {
             UserId = e.Value.GlobalId(),
             DepotRoleId = id
         };
         DataContext.DepotUserRole.Add(userRole);
         DataContext.SaveChanges();
         view.Rebind();
         search.Text = string.Empty;
         NotifyOK(ap, "用户成功加入角色");
     }
 }