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();
                }
            }
        }
Exemplo n.º 2
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();
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Updates the current Clan
        /// </summary>
        public static void Update(Clan clan)
        {
            using (var dbContext = new HouseOfClansEntities())
            {
                Clan clanInfo = ClanManager.SelectByClanId(clan.id);
                clanInfo.updatedOn = DateTime.Now;

                dbContext.Clans.Attach(clanInfo);
                dbContext.Entry(clanInfo).CurrentValues.SetValues(clan);
                dbContext.SaveChanges();
            }
        }
Exemplo n.º 4
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();
            }
        }
        /// <summary>
        /// Inserts or Updates the Clan War Picks depending on the parameters received.
        /// </summary>
        /// <param name="clanWarPickViewModel">A ClanWarPickViewModel object, if its Id is NULL then do an Insert, else Updates.</param>
        public static void Upsert(List<ClanWarPickViewModel> clanWarPicksList)
        {
            using (var dbContext = new HouseOfClansEntities())
            {
                foreach (ClanWarPickViewModel pick in clanWarPicksList)
                {
                    ClanWarPick clanWarPick = ClanWarPicksManager.ConvertViewToModel(pick);

                    if (pick.Id == null)
                    {
                        clanWarPick.addedOn = DateTime.Now;
                        dbContext.ClanWarPicks.Add(clanWarPick);
                    }
                    else
                    {
                        clanWarPick.updatedOn = DateTime.Now;
                        dbContext.Entry(clanWarPick).State = EntityState.Modified;
                        dbContext.Entry(clanWarPick).Property(p => p.clanMemberWarPosition).IsModified = false;
                    }

                    dbContext.SaveChanges();
                }
            }
        }
Exemplo n.º 6
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();
     }
 }
Exemplo n.º 7
0
        public static void Upsert(List<WarRanking> rankings)
        {
            using (var dbContext = new HouseOfClansEntities())
            {
                //vv The next line helps debugging. It will write to the Output window the sql statements
                //vv dbContext.Database.Log = s => System.Diagnostics.Debug.WriteLine(s);
                foreach (WarRanking ranking in rankings)
                {
                    if (ranking.id == 0)
                    {
                        ranking.addedOn = DateTime.Now;
                        dbContext.WarRankings.Add(ranking);
                    }
                    else
                    {
                        ranking.updatedOn = DateTime.Now;
                        dbContext.Entry(ranking).State = EntityState.Modified;
                    }

                    dbContext.SaveChanges();
                }
            }
        }