예제 #1
0
 private void RoleBanCheckBox_Click(object sender, RoutedEventArgs e)
 {
     if (RoleAdminCheckBox.IsChecked == true)
     {
         RoleBannedCheckBox.IsChecked = false;
         MessageBox.Show("Admin can't be banned!");
         return;
     }
     else if (RoleModerCheckBox.IsChecked == true)
     {
         RoleBannedCheckBox.IsChecked = false;
         MessageBox.Show("Moderator can't be banned!");
         return;
     }
     if (RoleBannedCheckBox.IsChecked == false)
     {
         var userinrole = from q in forumEntities.UsersInRoles
                          where q.UserId == curUser.UserId && q.RoleId == RoleBannedID
                          select q;
         UsersInRoles UserInRoleDel = userinrole.First();
         forumEntities.DeleteObject(UserInRoleDel);
         curUser.IsLocked = false;
         curUser.LockedDateOut = DateTime.Now;
     }
     else
     {
         //BAN info
         BanParameters BanPar = new BanParameters(curUser);
         BanPar.ShowDialog();
         if (curUser.LockedDateOut.Date <= DateTime.Now.Date)
         {
             RoleBannedCheckBox.IsChecked = false;
             return;
         }
         //ban
         {
             UsersInRoles UserInRoleAdd = new UsersInRoles();
             UserInRoleAdd = new UsersInRoles();
             UserInRoleAdd.RoleId = RoleBannedID;
             UserInRoleAdd.UserId = curUser.UserId;
             forumEntities.UsersInRoles.AddObject(UserInRoleAdd);
             curUser.IsLocked = true;
             //
             Post postBan = new Post();
             postBan.DateAdded = DateTime.Now;
             postBan.ForumID = (from q in forumEntities.Forum
                                    where q.ForumName == "usersprivateforum"
                                    select q).First().ForumID;
             postBan.TopicID = (from q in forumEntities.Topic
                                where q.TopicName == curUser.UserLoweredName + "privatetopicin"
                                select q).First().TopicID;
             postBan.Text = "You are banned!\nDate: " + curUser.LockedDateOut.ToString() + "\nReason: " + curUser.LockedReason;
             postBan.UserId = LoginedUser.UserId;
             forumEntities.AddToPost(postBan);
         }
     }
     forumEntities.SaveChanges();
     FillProfile();
 }
예제 #2
0
 /// <summary>
 /// Deprecated Method for adding a new object to the UsersInRoles EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToUsersInRoles(UsersInRoles usersInRoles)
 {
     base.AddObject("UsersInRoles", usersInRoles);
 }
예제 #3
0
        private void RoleModerCheckBox_Click(object sender, RoutedEventArgs e)
        {
            if (RoleBannedCheckBox.IsChecked == true)
            {
                RoleModerCheckBox.IsChecked = false;
                MessageBox.Show("Banned user can't become moderator!");
                return;
            }
            if (RoleModerCheckBox.IsChecked == false)
            {
                if (RoleAdminCheckBox.IsChecked == true)
                {
                    RoleModerCheckBox.IsChecked = true;
                    MessageBox.Show("Admin is always moderator!");
                    return;
                }

                var userinrole = from q in forumEntities.UsersInRoles
                                 where q.UserId == curUser.UserId && q.RoleId == RoleModerID
                                 select q;
                UsersInRoles UserInRoleDel = userinrole.First();
                forumEntities.DeleteObject(UserInRoleDel);
            }
            else
            {
                UsersInRoles UserInRoleAdd = new UsersInRoles();
                UserInRoleAdd = new UsersInRoles();
                UserInRoleAdd.RoleId = RoleModerID;
                UserInRoleAdd.UserId = curUser.UserId;
                forumEntities.UsersInRoles.AddObject(UserInRoleAdd);
            }
            forumEntities.SaveChanges();
        }
예제 #4
0
 /// <summary>
 /// Create a new UsersInRoles object.
 /// </summary>
 /// <param name="userId">Initial value of the UserId property.</param>
 /// <param name="roleId">Initial value of the RoleId property.</param>
 public static UsersInRoles CreateUsersInRoles(global::System.Guid userId, global::System.Guid roleId)
 {
     UsersInRoles usersInRoles = new UsersInRoles();
     usersInRoles.UserId = userId;
     usersInRoles.RoleId = roleId;
     return usersInRoles;
 }