Пример #1
0
        public static List<WarRanking> SelectRankingsByClanWarId(int id, bool sortedByPick)
        {
            List<WarRanking> rankings = new List<WarRanking>();

            using (var dbContext = new HouseOfClansEntities())
            {
                rankings = dbContext.WarRankings.Where(p => p.clanWarId == id && !p.optOut).ToList();

                if (sortedByPick)
                {
                    List<ClanWarPick> warMapMembers = ClanWarPicksManager.SelectAllByWarId(id).ToList();
                    List<WarRanking> sortedRankings = new List<WarRanking>();

                    warMapMembers.ForEach(delegate(ClanWarPick sortedPick)
                    {
                        WarRanking sortedRanking = rankings.Where(p => p.clanUserId == sortedPick.clanUserId).FirstOrDefault();

                        if (sortedRanking != null && sortedRanking.clanWarId == id)
                        {
                            sortedRankings.Add(sortedRanking);
                        }
                    });

                    rankings = new List<WarRanking>();
                    rankings = sortedRankings;
                }
            }

            return rankings;
        }
Пример #2
0
 /// <summary>
 /// Inserts a new Clan record
 /// </summary>
 public static void Insert(Clan clan)
 {
     using (var dbContext = new HouseOfClansEntities())
     {
         clan.addedOn = DateTime.Now;
         dbContext.Clans.Add(clan);
         dbContext.SaveChanges();
     }
 }
Пример #3
0
 /// <summary>
 /// Inserts a new UserBlackList record
 /// </summary>
 public static void Insert(UserBlackList bUser)
 {
     using (var dbContext = new HouseOfClansEntities())
     {
         bUser.addedOn = DateTime.Now;
         dbContext.UserBlackLists.Add(bUser);
         dbContext.SaveChanges();
     }
 }
Пример #4
0
 /// <summary>
 /// Inserts a new Rule
 /// </summary>
 public static void Insert(Rule rule)
 {
     using (var dbContext = new HouseOfClansEntities())
     {
         rule.addedOn = DateTime.Now;
         dbContext.Rules.Add(rule);
         dbContext.SaveChanges();
     }
 }
Пример #5
0
        /// <summary>
        /// Gets the clan user information based on the aspnet user id
        /// </summary>
        /// <param name="aspnetUserId">AspNetUser Id</param>
        public static ClanUser SelectByAspNetUserId(string aspnetUserId)
        {
            ClanUser clanUser = new ClanUser();
            using (var dbContext = new HouseOfClansEntities())
            {
                clanUser = dbContext.ClanUsers.Where(p => p.aspnetUserId == aspnetUserId).Select(user => user).FirstOrDefault();
            }

            return clanUser;
        }
Пример #6
0
        /// <summary>
        /// Gets a ClanGroup based on the ClanGroup id
        /// </summary>
        /// <param name="clanId">Clan Id</param>
        public static ClanGroup SelectByClanGroupId(int clanGroupId)
        {
            ClanGroup clanGroup = new ClanGroup();

            using (var dbContext = new HouseOfClansEntities())
            {
                clanGroup = dbContext.ClanGroups.Where(p => p.id == clanGroupId).FirstOrDefault();
            }

            return clanGroup;
        }
Пример #7
0
        /// <summary>
        /// Gets a list of ClanGroups based on the clan id
        /// </summary>
        /// <param name="clanId">Clan Id</param>
        public static List<ClanGroup> SelectAllByClanId(int? clanId)
        {
            List<ClanGroup> clanGroups = new List<ClanGroup>();

            using (var dbContext = new HouseOfClansEntities())
            {
                clanGroups = dbContext.ClanGroups.Where(p => p.clanId == clanId).ToList();
            }

            return clanGroups;
        }
        /// <summary>
        /// Gets a list of War Picks based on the war id
        /// </summary>
        /// <param name="warId">War Id</param>
        public static List<ClanWarPick> SelectAllByWarId(int warId)
        {
            List<ClanWarPick> warPicks = new List<ClanWarPick>();

            using (var dbContext = new HouseOfClansEntities())
            {
                warPicks = dbContext.ClanWarPicks.Where(p => p.clanWarId == warId).OrderBy(p => p.clanMemberWarPosition).ToList();
            }

            return warPicks;
        }
Пример #9
0
        /// <summary>
        /// Gets a list of rules based on the clan id
        /// </summary>
        /// <param name="clanId">Clan Id</param>
        public static List<Rule> SelectAllByClanId(int? clanId)
        {
            List<Rule> rules = new List<Rule>();

            using (var dbContext = new HouseOfClansEntities())
            {
                rules = dbContext.Rules.Where(p => p.clanId == clanId).ToList();
            }

            return rules;
        }
Пример #10
0
        /// <summary>
        /// Gets a UserBlacklist based on the blacklist id
        /// </summary>
        /// <param name="userBlacklistId">UserBlacklist Id</param>
        public static UserBlackList SelectByBlacklistId(int blacklistId)
        {
            UserBlackList blacklist = new UserBlackList();

            using (var dbContext = new HouseOfClansEntities())
            {
                blacklist = dbContext.UserBlackLists.Where(p => p.id == blacklistId).FirstOrDefault();
            }

            return blacklist;
        }
Пример #11
0
        /// <summary>
        /// Gets the list of UserBlackList based on the clan id
        /// </summary>
        /// <param name="clanId">Clan Id</param>
        public static List<UserBlackList> SelectBlackListsByClanId(int clanId)
        {
            List<UserBlackList> userBlacklists = new List<UserBlackList>();

            using (var dbContext = new HouseOfClansEntities())
            {
                userBlacklists = dbContext.UserBlackLists.Where(p => p.clanId == clanId).ToList();
            }

            return userBlacklists;
        }
Пример #12
0
        /// <summary>
        /// Gets a rule based on the rule id
        /// </summary>
        /// <param name="clanId">Clan Id</param>
        public static Rule SelectByRuleId(int ruleId)
        {
            Rule rule = new Rule();

            using (var dbContext = new HouseOfClansEntities())
            {
                rule = dbContext.Rules.Where(p => p.id == ruleId).FirstOrDefault();
            }

            return rule;
        }
Пример #13
0
        /// <summary>
        /// Gets the list of all available war types
        /// </summary>
        /// <returns>A WarType object list</returns>
        public static List<WarType> GetAll()
        {
            List<WarType> warTypes = new List<WarType>();

            using (var dbContext = new HouseOfClansEntities())
            {
                warTypes = dbContext.WarTypes.Select(warType => warType).OrderBy(p => p.id).ToList();
            }

            return warTypes;
        }
Пример #14
0
        public static WarType Get(int id)
        {
            WarType warType = new WarType();

            using (var dbContext = new HouseOfClansEntities())
            {
                warType = dbContext.WarTypes.Where(p => p.id == id).FirstOrDefault();
            }

            return warType;
        }
Пример #15
0
        /// <summary>
        /// Gets the clan information based on the clan id
        /// </summary>
        /// <param name="clanId">Clan Id</param>
        public static Clan SelectByClanId(int? clanId)
        {
            Clan clanInfo = new Clan();

            using (var dbContext = new HouseOfClansEntities())
            {
                clanInfo = dbContext.Clans.Where(p => p.id == clanId).Select(clan => clan).FirstOrDefault();
            }

            return clanInfo;
        }
Пример #16
0
        /// <summary>
        /// Gets the list of all available User Roles
        /// </summary>
        /// <returns>A UserRole object list</returns>
        public static List<UserRole> GetAll()
        {
            List<UserRole> userRoles = new List<UserRole>();

            using (var dbContext = new HouseOfClansEntities())
            {
                userRoles = dbContext.UserRoles.Select(userRole => userRole).ToList();
            }

            return userRoles;
        }
Пример #17
0
        /// <summary>
        /// Gets the User Role by id
        /// </summary>
        /// <returns>A UserRole object</returns>
        public static UserRole Get(int id)
        {
            UserRole userRole = new UserRole();

            using (var dbContext = new HouseOfClansEntities())
            {
                userRole = dbContext.UserRoles.Where(p => p.id == id).FirstOrDefault();
            }

            return userRole;
        }
Пример #18
0
        /// <summary>
        /// Gets the all members based on the clan id
        /// </summary>
        /// <param name="clanId">Clan Id</param>
        public static List<ClanUser> SelectAllByClanId(int clanId)
        {
            List<ClanUser> clanMembers = new List<ClanUser>();

            using (var dbContext = new HouseOfClansEntities())
            {
                clanMembers = dbContext.ClanUsers.Where(p => p.clanId == clanId).Select(user => user).ToList();
            }

            return clanMembers;
        }
Пример #19
0
        /// <summary>
        /// Get all users of the website. Rarely used. Right now only used on the 'hidden' logs page. Might be deprecated soon or moved to its ActionLog Manager/ModelView. //vv
        /// </summary>
        /// <returns>A list of all ClanUsers of the website</returns>
        public static List<ClanUser> SelectAll()
        {
            List<ClanUser> clanMembers = new List<ClanUser>();

            using (var dbContext = new HouseOfClansEntities())
            {
                clanMembers = dbContext.ClanUsers.ToList();
            }

            return clanMembers;
        }
Пример #20
0
        /// <summary>
        /// Updates a Rule
        /// </summary>
        public static void Update(Rule rule)
        {
            using (var dbContext = new HouseOfClansEntities())
            {
                Rule ruleInfo = RuleManager.SelectByRuleId(rule.id);
                ruleInfo.updatedOn = DateTime.Now;

                dbContext.Rules.Attach(ruleInfo);
                dbContext.Entry(ruleInfo).CurrentValues.SetValues(rule);
                dbContext.SaveChanges();
            }
        }
Пример #21
0
 /// <summary>
 /// Updates a UserBlackList
 /// </summary>
 public static void Update(UserBlackList updatedBUser)
 {
     UserBlackList bUser = BlacklistManager.SelectByBlacklistId(updatedBUser.id);
     using (var dbContext = new HouseOfClansEntities())
     {
         //TODO: Add updatedOn for the UserBlackList entity in the database
         //updatedBUser.updatedOn = DateTime.Now;
         dbContext.UserBlackLists.Attach(bUser);
         dbContext.Entry(bUser).CurrentValues.SetValues(updatedBUser);
         dbContext.SaveChanges();
     }
 }
Пример #22
0
        /// <summary>
        /// Updates a ClanGroup
        /// </summary>
        public static void Update(ClanGroup clanGroup)
        {
            using (var dbContext = new HouseOfClansEntities())
            {
                ClanGroup clanGroupInfo = ClanGroupManager.SelectByClanGroupId(clanGroup.id);
                clanGroupInfo.updatedOn = DateTime.Now;

                dbContext.ClanGroups.Attach(clanGroupInfo);
                dbContext.Entry(clanGroupInfo).CurrentValues.SetValues(clanGroup);
                dbContext.SaveChanges();
            }
        }
Пример #23
0
        public static List<WarRanking> SelectRankingsByClanId(int clanId)
        {
            List<WarRanking> allClanMembersRankings = new List<WarRanking>();
            List<int> clanMembers = ClanUserManager.SelectAllByClanId(clanId).Where(p => (Enums.ClanRole)p.userRoleId != Enums.ClanRole.Unknown).OrderBy(o => o.userRoleId).Select(p => p.id).ToList();

            using (var dbContext = new HouseOfClansEntities())
            {
                allClanMembersRankings = dbContext.WarRankings.Where(p => clanMembers.Contains(p.clanUserId)).Select(ranking => ranking).ToList();
            }

            return allClanMembersRankings;
        }
Пример #24
0
        /// <summary>
        /// Deletes a UserBlackList
        /// </summary>
        public static bool Delete(int blacklistId)
        {
            bool isDeleted = false;
            UserBlackList deleteBlacklist = BlacklistManager.SelectByBlacklistId(blacklistId);

            using (var dbContext = new HouseOfClansEntities())
            {
                dbContext.UserBlackLists.Attach(deleteBlacklist);
                dbContext.UserBlackLists.Remove(deleteBlacklist);
                isDeleted = dbContext.SaveChanges() > 0;
            }

            return isDeleted;
        }
        /// <summary>
        /// Deletes the Picks of the current Clan War
        /// </summary>
        public static bool Delete(int warId)
        {
            bool isDeleted = false;

            using (var dbContext = new HouseOfClansEntities())
            {
                dbContext.ClanWarPicks.RemoveRange(dbContext.ClanWarPicks.Where(p => p.clanWarId == warId));
                dbContext.SaveChanges();
            }

            isDeleted = !ClanWarPicksManager.SelectAllByWarId(warId).Any();

            return isDeleted;
        }
Пример #26
0
        /// <summary>
        /// Deletes a rule
        /// </summary>
        public static bool Delete(int ruleId)
        {
            bool isDeleted = false;
            Rule deleteRule = RuleManager.SelectByRuleId(ruleId);

            using (var dbContext = new HouseOfClansEntities())
            {
                dbContext.Rules.Attach(deleteRule);
                dbContext.Rules.Remove(deleteRule);
                isDeleted = dbContext.SaveChanges() > 0;
            }

            return isDeleted;
        }
Пример #27
0
        /// <summary>
        /// Deletes the current Clan
        /// </summary>
        public static bool Delete(int clanId)
        {
            bool isDeleted = false;
            Clan deleteClan = ClanManager.SelectByClanId(clanId);

            using (var dbContext = new HouseOfClansEntities())
            {
                dbContext.Clans.Attach(deleteClan);
                dbContext.Clans.Remove(deleteClan);
                isDeleted = dbContext.SaveChanges() > 0;
            }

            return isDeleted;
        }
Пример #28
0
 ///<summar>
 /// Gets the clan id based on a AspNet User Id
 /// </summar>
 public static int? GetClanId(string aspnetId)
 {
     ClanUser clanUser;
     using (var dbContext = new HouseOfClansEntities())
     {
         clanUser = dbContext.ClanUsers.Where(p => p.aspnetUserId == aspnetId).Select(clan => clan).FirstOrDefault();
     }
     if (clanUser == null)
     {
         return null;
     }
     else
     {
         return clanUser.clanId;
     }
 }
        public static void UpdateMemberWarPosition(string[] sortedPicks)
        {
            string idParsed = string.Empty;

            using (var dbContext = new HouseOfClansEntities())
            {
                for (short i = 0; i < sortedPicks.Length; i++)
                {
                    idParsed = sortedPicks[i].Replace(_clanWarPickSortedName, "");

                    ClanWarPick pick = new ClanWarPick()
                    {
                        id = int.Parse(idParsed),
                        clanMemberWarPosition = (short)(i + 1),
                        updatedOn = DateTime.Now
                    };

                    dbContext.ClanWarPicks.Attach(pick);
                    dbContext.Entry(pick).Property(p => p.clanMemberWarPosition).IsModified = true;
                    dbContext.Entry(pick).Property(p => p.updatedOn).IsModified = true;
                    dbContext.SaveChanges();
                }
            }
        }
Пример #30
0
        /// <summary>
        /// Updates the current Clan User
        /// </summary>
        public static void Update(ClanUser updatedClanUser)
        {
            ClanUser clanUser = ClanUserManager.SelectByClanUserId(updatedClanUser.id);
            using (var dbContext = new HouseOfClansEntities())
            {

                updatedClanUser.updatedOn = DateTime.Now;
                dbContext.ClanUsers.Attach(clanUser);
                dbContext.Entry(clanUser).CurrentValues.SetValues(updatedClanUser);
                dbContext.SaveChanges();
            }
        }