public async Task <Collection <Company> > findEmployee(IUser user) { Collection <Company> companies = new Collection <Company>(); foreach (JObject x in JArray.FromObject(await __database.GetFieldAsync(user.Id.ToString(), "companies", "users"))) { companies.Add(await getCompany((string)x)); } return(companies); }
public async Task AdvanceAllAsync(SocketGuild guild, int amount) { IGuild guildx = (IGuild)guild; IReadOnlyCollection <IGuildUser> users = await guildx.GetUsersAsync(); foreach (IGuildUser x in users) { if (x.IsBot) { continue; } string ageTemporary; int age; ageTemporary = (string)await __database.GetFieldAsync(x.Id.ToString(), "age", "users"); if (ageTemporary == null) { Random rand = new Random(); //Set up a RNG age = rand.Next(20, 25); //Get num between 20 and 25 } else { age = int.Parse(ageTemporary); } int ageNew = age + amount; await __database.SetFieldAsync(x.Id.ToString(), "age", ageNew, "users"); int pp; string ppTemporary; ppTemporary = (string)await __database.GetFieldAsync(x.Id.ToString(), "pp", "users"); if (ppTemporary == null) { pp = 0; } else { pp = int.Parse(ppTemporary); } int newpp = pp - (int)Math.Floor(((double.Parse(pp.ToString()) / 100) * amount)); await __database.SetFieldAsync(x.Id.ToString(), "pp", newpp, "users"); int expectancy; string expectancyTemporary; expectancyTemporary = (string)await __database.GetFieldAsync(x.Id.ToString(), "expectancy", "users"); if (expectancyTemporary == null) { Random rand = new Random(); //Set up a RNG expectancy = rand.Next(90, 130); //Get num between 90 and 130 await __database.SetFieldAsync(x.Id.ToString(), "expectancy", expectancy, "users"); } else { expectancy = int.Parse(expectancyTemporary); } if (ageNew >= expectancy) { await KillAsync(x); } string money = (string)await __database.GetFieldAsync(x.Id.ToString(), "money", "users"); double moneyd; if (money == null) { moneyd = 50000; await __database.SetFieldAsync <double>(x.Id.ToString(), "money", moneyd, "users"); } else { moneyd = (1300 * amount) + double.Parse(money); await __database.SetFieldAsync <double>(x.Id.ToString(), "money", moneyd, "users"); } } }