Inheritance: System.Data.Objects.DataClasses.EntityObject
Esempio n. 1
0
        public bool AddModerator(string subforum, string moderatorName)
        {
            try
            {
                ModeratorEntity me = new ModeratorEntity();
                me.Username = moderatorName;
                me.Subforum = subforum;
                ForumContext.ModeratorEntities.AddObject(me);
                ForumContext.SaveChanges();
                return true;
            }
            catch (Exception)
            {

                throw;
            }
            //try
            //{
            //    // Update in moderators table
            //    IEnumerable<ModeratorEntity> getModeratorQuery = from m in ForumContext.ModeratorEntities
            //                                                     where m.Subforum == subforum && m.Username == moderatorName
            //                                                     select m;

            //    // Update in users table

            //    IEnumerable<ModeratorEntity> userIsStillModeratorQuery = from m in ForumContext.ModeratorEntities
            //                                                             where m.Username == moderatorName
            //                                                             select m;
            //    UserEntity ue = null;
            //    if (userIsStillModeratorQuery.Count() == 1)     // If user was just moderator of subforum then change his status in yblUsers
            //    {
            //        IEnumerable<UserEntity> usersQuery = from u in ForumContext.UserEntities
            //                                             where u.UserName == moderatorName
            //                                             select u;
            //        ue = usersQuery.First();
            //        ue.Authentication = AuthorizationLevel.MEMBER.ToString();
            //    }
            //    ForumContext.ModeratorEntities.DeleteObject(getModeratorQuery.First());

            //    ForumContext.SaveChanges();
            //    return true;
            //}
            //catch (Exception)
            //{
            //    //TODO
            //    throw;
            //}
        }
Esempio n. 2
0
        public bool SetModerators(string subforum, List<string> moderatorsList)
        {
            try
            {
                foreach (string modName in moderatorsList)
                {
                    ModeratorEntity me = new ModeratorEntity();
                    me.Username = modName;
                    me.Subforum = subforum;
                    ForumContext.ModeratorEntities.AddObject(me);

                    IEnumerable<UserEntity> usersQuery = from u in ForumContext.UserEntities
                                                         where u.UserName == modName
                                                         select u;
                    usersQuery.First().Authentication = AuthorizationLevel.MODERATOR.ToString();

                }
                ForumContext.SaveChanges();
                return true;
            }
            catch (Exception)
            {
                //TODO
                throw;
            }
        }
Esempio n. 3
0
 /// <summary>
 /// Create a new ModeratorEntity object.
 /// </summary>
 /// <param name="username">Initial value of the Username property.</param>
 /// <param name="subforum">Initial value of the Subforum property.</param>
 public static ModeratorEntity CreateModeratorEntity(global::System.String username, global::System.String subforum)
 {
     ModeratorEntity moderatorEntity = new ModeratorEntity();
     moderatorEntity.Username = username;
     moderatorEntity.Subforum = subforum;
     return moderatorEntity;
 }
Esempio n. 4
0
 /// <summary>
 /// Deprecated Method for adding a new object to the ModeratorEntities EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToModeratorEntities(ModeratorEntity moderatorEntity)
 {
     base.AddObject("ModeratorEntities", moderatorEntity);
 }