public static GuildSlim GetGuild(string guildJson) { var jObject = JsonConvert.DeserializeObject(guildJson) as JObject; var guild = new GuildSlim() { Name = jObject.SelectToken("name").ToString(), Realm = jObject.SelectToken("realm").ToString(), Battlegroup = jObject.SelectToken("battlegroup").ToString() }; return(guild); }
public async Task <int> CreateGuildProfileAsync( string creatorId, string profileName, GuildSlim guild, EfModels.StoredBlizzardModels.StoredRealm realm, EfEnums.GameRegionEnum region, bool isPublic) { using (var transaction = await this.context.Database.BeginTransactionAsync()) { var newProfile = new EF.Models.GuildProfile() { CreatorId = creatorId, ProfileName = profileName, RealmId = realm.Id, IsPublic = isPublic }; this.context.GuildProfile.Add(newProfile); await this.context.SaveChangesAsync(); EfModels.StoredBlizzardModels.StoredGuild storedGuild = new EfModels.StoredBlizzardModels.StoredGuild() { Name = guild.Name, RealmId = realm.Id, ProfileId = newProfile.Id }; this.context.StoredGuilds.Add(storedGuild); newProfile.CreatorGuild = storedGuild; if (!isPublic) { this.context.User_GuildProfilePermissions.Add(new EF.Models.User_GuildProfilePermissions() { PermissionLevelId = (int)EF.Models.Enums.GuildProfilePermissionLevel.Admin, ProfileId = newProfile.Id, UserId = creatorId }); } await this.context.SaveChangesAsync(); transaction.Commit(); return(newProfile.Id); } }