Exemplo n.º 1
0
 public void SaveToDatabase()
 {
     using (LeattyContext DBContext = new LeattyContext())
     {
         DB.Models.Guild UpdateGuild = DBContext.Guilds.Single(x => x.Id == GuildId);
         UpdateGuild.Id          = GuildId;
         UpdateGuild.Leader      = LeaderId;
         UpdateGuild.GP          = GP;
         UpdateGuild.Logo        = Logo;
         UpdateGuild.LogoColor   = LogoColor;
         UpdateGuild.LogoBG      = LogoBG;
         UpdateGuild.LogoBGColor = LogoBGColor;
         UpdateGuild.Rank1Title  = RankTitles[0];
         UpdateGuild.Rank2Title  = RankTitles[1];
         UpdateGuild.Rank3Title  = RankTitles[2];
         UpdateGuild.Rank4Title  = RankTitles[3];
         UpdateGuild.Rank5Title  = RankTitles[4];
         UpdateGuild.Capacity    = Capacity;
         UpdateGuild.Notice      = Notice;
         UpdateGuild.Signature   = Signature;
         UpdateGuild.AllianceId  = Alliance;
         DBContext.Entry <DB.Models.Guild>(UpdateGuild).State = System.Data.Entity.EntityState.Modified;
         DBContext.SaveChanges();
     }
 }
Exemplo n.º 2
0
        public static MapleGuild CreateGuild(string name, MapleCharacter leader)
        {
            foreach (MapleGuild g in Guilds.Values)
            {
                if (g.Name.Equals(name, StringComparison.CurrentCultureIgnoreCase))
                {
                    return(null);
                }
            }
            using (LeattyContext DBContext = new LeattyContext())
            {
                DB.Models.Guild InsertGuild = new DB.Models.Guild();
                InsertGuild.Leader = leader.Id;
                InsertGuild.Name   = name;
                DBContext.Guilds.Add(InsertGuild);
                Character DbChar = DBContext.Characters.SingleOrDefault(x => x.Id == leader.Id);
                DbChar.GuildContribution = 500;
                DbChar.AllianceRank      = 5;
                DbChar.GuildRank         = 1;
                DBContext.Entry <Character>(DbChar).State = System.Data.Entity.EntityState.Modified;
                DBContext.SaveChanges();

                MapleGuild gld = new MapleGuild();
                gld.GuildId     = InsertGuild.Id;
                gld.LeaderId    = leader.Id;
                gld.GP          = 0;
                gld.Logo        = 0;
                gld.LogoColor   = 0;
                gld.Name        = name;
                gld.Capacity    = 10;
                gld.LogoBG      = 0;
                gld.LogoBGColor = 0;
                gld.Notice      = null;
                gld.Signature   = 0;
                gld.Alliance    = 0;
                Guilds.Add(gld.GuildId, gld);
                return(gld);
            }
        }