public async Task ResetInvoiceAsync() { SocketGuildUser User1 = Context.User as SocketGuildUser; if (!User1.GuildPermissions.ManageChannels) { await Context.User.SendMessageAsync("You do not have the required permission to use this command. If it is necessary, contact someone with the Admin role here"); await Context.Message.DeleteAsync(); return; } using (var DbContext = new SqliteDbContext()) { IQueryable <Invoice> ResetInvoice = DbContext.Invoice.Where(x => x.Amount > 0); foreach (Invoice Amount in ResetInvoice) { Amount.Amount = 0; } ; await DbContext.SaveChangesAsync(); await Context.User.SendMessageAsync("This message is only sent after the database changes have been saved, and hence confirms success of your reset!"); await Context.Message.DeleteAsync(); } }
public static int ReviveRecord(ulong UserId) { using (var DbContext = new SqliteDbContext()) { int result = DbContext.Invoice.Sum(a => a.Amount); return(result); } }
public static int SeeProfile(ulong UserId) { using (var DbContext = new SqliteDbContext()) { if (DbContext.Invoice.Where(x => x.UserId == UserId).Count() < 1) { return(0); } return(DbContext.Invoice.Where(x => x.UserId == UserId).Select(x => x.Profile).FirstOrDefault()); } }
public static async Task SaveRecord(ulong UserId, int Amount, int Profile) { using (var DbContext = new SqliteDbContext()) { if (DbContext.Invoice.Where(x => x.UserId == UserId).Count() < 1) { DbContext.Invoice.Add(new Invoice { UserId = UserId, Amount = Amount, Profile = Profile }); } else { Invoice Current = DbContext.Invoice.Where(x => x.UserId == UserId).FirstOrDefault(); Current.Amount += 1; DbContext.Invoice.Update(Current); } await DbContext.SaveChangesAsync(); } }