/// <summary> /// Sells a <see cref="Fish" /> to the "market", then adds the value of the fish to the /// <see cref="User" />'s points balance. This action will add the points to the user's account. /// This method is synchronous as of v2.5.2 due to errors relating to users not getting points when mass-selling fish. /// </summary> /// <param name="fish">The fish to sell.</param> /// <param name="userId">The ID of the user to add the value of the fish to.</param> /// <returns>The new total amount of points the user has.</returns> public static int SellFish(Fish fish, ulong userId) { User user = GetOrCreateUserAsync(userId).Result; user.Points += Fish.GetPayoutForFish(fish, user.FishExp); fish.Sold = true; using (var db = new KaguyaDb()) { db.UpdateAsync(fish); db.UpdateAsync(user); } return(user.Points); }
/// <summary> /// Updates the specified <see cref="IEnumerable{T}" /> <see cref="args" /> in the database. /// </summary> /// <typeparam name="T">The type of object whom's collection we are updating.</typeparam> /// <param name="args">The collection to update.</param> /// <returns></returns> public static async Task UpdateAsync <T>(IEnumerable <T> args) where T : class, IKaguyaQueryable <T>, IKaguyaUnique <T> { using (var db = new KaguyaDb()) { foreach (T arg in args) { await db.UpdateAsync(arg); } } }
/// <summary> /// Updates the specified <see cref="IKaguyaUnique{T}" /> <see cref="arg" /> in the database. Item /// must have a primary key in order for this query to execute. /// </summary> /// <typeparam name="T">The type of object we are updating</typeparam> /// <param name="arg">The object to update.</param> /// <returns></returns> public static async Task UpdateAsync <T>(T arg) where T : class, IKaguyaQueryable <T>, IKaguyaUnique <T> { using (var db = new KaguyaDb()) await db.UpdateAsync(arg); }