Beispiel #1
0
 protected void submitButton_Click(object sender, EventArgs e)
 {
     foreach (ListItem v in UsersCheckBoxList.Items)
     {
         if (v.Selected)
         {
             if (!Roles.IsUserInRole(v.Value, "service"))
             {
                 Roles.AddUserToRole(v.Value, "service");
             }
             var uid = (Guid)Membership.GetUser(v.Value).ProviderUserKey;
             if (this.db.Services.Count(serv => serv.UserId == uid) == 0)
             {
                 Service s = new Service();
                 s.UserId = uid;
                 s.Address = "";
                 s.Name = "";
                 this.db.Services.InsertOnSubmit(s);
             }
         }
         else
         {
             if (Roles.IsUserInRole(v.Value, "service"))
             {
                 Roles.RemoveUserFromRole(v.Value, "service");
             }
         }
     }
     this.db.SubmitChanges();
 }
 partial void UpdateService(Service instance);
 partial void DeleteService(Service instance);
 partial void InsertService(Service instance);