示例#1
0
 public async Task RemoveCurrencyAsync(MikiContext context, User sentTo, int amount)
 {
     Currency -= amount;
     await context.SaveChangesAsync();
 }
示例#2
0
 public static async Task <LocalExperience> GetAsync(MikiContext context, long serverId, long userId)
 {
     return(await context.LocalExperience.FindAsync(serverId, userId)
            ?? await CreateAsync(context, serverId, userId));
 }
示例#3
0
 public static async Task <bool> ExistsAsync(MikiContext context, ulong id1, ulong id2)
 => await ExistsAsync(context, id1.ToDbLong(), id2.ToDbLong());
示例#4
0
 public static async Task <List <Marriage> > GetProposalsReceived(MikiContext context, long asker)
 => await InternalGetProposalsReceivedAsync(context, asker);
示例#5
0
 public static async Task <bool> IsBeingProposedBy(MikiContext context, long MarriageId)
 {
     return(await InternalGetProposalAsync(context, MarriageId) != null);
 }
示例#6
0
 public void AcceptProposal(MikiContext context)
 {
     TimeOfMarriage = DateTime.Now;
     IsProposing    = false;
 }
示例#7
0
 public static List <Marriage> GetMarriages(MikiContext context, long userid)
 {
     return(InternalGetMarriages(context, userid));
 }
示例#8
0
 public GlobalPasta GetParent(MikiContext context)
 {
     return(context.Pastas.Find(Id));
 }
示例#9
0
 public static List <Marriage> GetProposalsReceived(MikiContext context, long asker) => InternalGetProposalsReceived(context, asker);
示例#10
0
 public static Marriage GetMarriage(MikiContext context, ulong receiver, ulong asker) => GetMarriage(context, receiver.ToDbLong(), asker.ToDbLong());
示例#11
0
 public static async Task <Marriage> GetProposalReceivedAsync(MikiContext context, ulong receiver, ulong asker)
 {
     return(await GetProposalReceivedAsync(context, receiver.ToDbLong(), asker.ToDbLong()));
 }
示例#12
0
 public void Remove(MikiContext context)
 {
     context.UsersMarriedTo.Remove(this);
 }
示例#13
0
 public static async Task <int> GetRankAsync(MikiContext context, long serverId, long userId)
 {
     return(await(await GetAsync(context, serverId, userId)).GetRank(context));
 }
示例#14
0
 public static bool ExistsAsMarriage(MikiContext context, long id1, long id2)
 {
     return(GetMarriage(context, id1, id2) != null);
 }
示例#15
0
 public static async Task <bool> IsBeingProposedBy(MikiContext context, long receiver, long asker)
 {
     return(await InternalGetProposalAsync(context, receiver, asker) != null);
 }
示例#16
0
 public static User CreateAsync(MikiContext m, IDiscordMessage e)
 {
     return(Create(m, e.Author));
 }
示例#17
0
 private static async Task <Marriage> InternalGetProposalAsync(MikiContext context, long receiver, long asker)
 {
     return(await context
            .Marriages
            .FindAsync(receiver, asker));
 }
示例#18
0
 public static async Task <List <Marriage> > GetMarriagesAsync(MikiContext context, long userid)
 {
     return(await InternalGetMarriagesAsync(context, userid));
 }
示例#19
0
 private static List <Marriage> InternalGetProposalsSent(MikiContext context, long asker)
 {
     return(context.Marriages.Where(p => p.Id1 == asker && p.Proposing == true).ToList());
 }
示例#20
0
 private static async Task <List <Marriage> > InternalGetProposalsReceivedAsync(MikiContext context, long receiver)
 {
     return(await context.Marriages
            .Where(p => p.Participants.FirstOrDefault(x => x.UserId == receiver && !x.Asker) != null && p.IsProposing == true)
            .Include(x => x.Participants)
            .ToListAsync());
 }
示例#21
0
 private static List <Marriage> InternalGetProposalsReceived(MikiContext context, long receiver)
 {
     return(context.Marriages.Where(p => p.Id2 == receiver && p.Proposing == true).ToList());
 }
示例#22
0
 public async Task RemoveAsync(MikiContext context)
 {
     context.Marriages.Remove(this);
     await context.SaveChangesAsync();
 }
示例#23
0
 private static Marriage InternalGetMarriage(MikiContext context, long receiver, long asker)
 {
     return(context.Marriages.Where(tm => tm.Id1 == receiver && tm.Id2 == asker && tm.Proposing == false).FirstOrDefault());
 }
示例#24
0
 public static async Task <bool> ExistsAsMarriageAsync(MikiContext context, long id1, long id2)
 => await GetMarriageAsync(context, id1, id2) != null;
示例#25
0
 public async Task DeclineProposalAsync(MikiContext context)
 {
     context.Marriages.Remove(this);
     await context.SaveChangesAsync();
 }
示例#26
0
 public static async Task <Marriage> GetMarriageAsync(MikiContext context, ulong receiver, ulong asker)
 => await GetMarriageAsync(context, receiver.ToDbLong(), asker.ToDbLong());
示例#27
0
 public static async Task <bool> ExistsAsync(MikiContext context, long id1, long id2)
 {
     return(await GetEntryAsync(context, id1, id2) != null);
 }
示例#28
0
 public bool IsDonator(MikiContext context)
 {
     return(context.Achievements.Find(Id, "donator") != null);
 }
示例#29
0
 public static async Task <List <User> > SearchUserAsync(MikiContext context, string name)
 {
     return(await context.Users
            .Where(x => x.Name.ToLower() == name.ToLower())
            .ToListAsync());
 }