public static async Task <bool> ProposeAsync(MikiContext context, long receiver, long asker) { Marriage m = context.Marriages.Add(new Marriage() { IsProposing = true, TimeOfProposal = DateTime.Now, TimeOfMarriage = DateTime.Now, }).Entity; m.Participants = new List <UserMarriedTo>(); m.Participants.Add(new UserMarriedTo() { MarriageId = m.MarriageId, UserId = receiver }); m.Participants.Add(new UserMarriedTo() { MarriageId = m.MarriageId, UserId = asker, Asker = true }); await context.SaveChangesAsync(); return(true); }
public static async Task BanAsync(long id) { using (var context = new MikiContext()) { User u = await context.Users.FindAsync(id); await Marriage.DivorceAllMarriagesAsync(context, id); await Marriage.DeclineAllProposalsAsync(context, id); context.CommandUsages.RemoveRange( await context.CommandUsages.Where(x => x.UserId == id).ToListAsync() ); context.Achievements.RemoveRange( await context.Achievements.Where(x => x.Id == id).ToListAsync() ); context.LocalExperience.RemoveRange( await context.LocalExperience.Where(x => x.UserId == id).ToListAsync() ); Bot.Instance.GetAttachedObject <EventSystem>().MessageFilter.Get <UserFilter>().Users.Add(id.FromDbLong()); u.Banned = true; u.Total_Commands = 0; u.Total_Experience = 0; u.MarriageSlots = 0; u.Currency = 0; u.Reputation = 0; await context.SaveChangesAsync(); } }
public static async Task <Marriage> GetProposalReceivedAsync(MikiContext context, long receiver, long asker) { Marriage m = null; m = await InternalGetProposalAsync(context, receiver, asker); return(m); }
public static Marriage GetMarriage(MikiContext context, long receiver, long asker) { Marriage m = null; m = InternalGetMarriage(context, receiver, asker); if (m == null) { m = InternalGetMarriage(context, asker, receiver); } return(m); }
public static async Task <Marriage> GetMarriageAsync(MikiContext context, long receiver, long asker) { Marriage m = null; m = await InternalGetMarriageAsync(context, receiver, asker); if (m == null) { m = await InternalGetMarriageAsync(context, asker, receiver); } return(m); }
public static async Task <Marriage> GetEntryAsync(MikiContext context, long receiver, long asker) { Marriage m = null; m = await context.Marriages.FindAsync(receiver, asker); if (m == null) { m = await context.Marriages.FindAsync(asker, receiver); } return(m); }
public static async Task <Marriage> GetEntryAsync(MikiContext context, long receiver, long asker) { Marriage m = null; m = await context.Marriages .Where(x => x.Participants .Any(c => c.UserId == receiver) && x.Participants .Any(c => c.UserId == asker)) .FirstOrDefaultAsync(); return(m); }
public static async Task ProposeAsync(long asker, long receiver) { using (var context = new MikiContext()) { Marriage m = context.Marriages.Add(new Marriage() { IsProposing = true, TimeOfProposal = DateTime.Now, TimeOfMarriage = DateTime.Now, }).Entity; context.UsersMarriedTo.Add(new UserMarriedTo() { MarriageId = m.MarriageId, ReceiverId = receiver, AskerId = asker }); await context.SaveChangesAsync(); } }
public static async Task <bool> ProposeAsync(long receiver, long asker) { try { using (var context = new MikiContext()) { Marriage m = context.Marriages.Add(new Marriage() { IsProposing = true, TimeOfProposal = DateTime.Now, TimeOfMarriage = DateTime.Now, }).Entity; await context.SaveChangesAsync(); context.UsersMarriedTo.Add(new UserMarriedTo() { MarriageId = m.MarriageId, UserId = receiver }); context.UsersMarriedTo.Add(new UserMarriedTo() { MarriageId = m.MarriageId, UserId = asker, Asker = true }); await context.SaveChangesAsync(); return(true); } } catch (Exception e) { Log.Message(e.Message + "\n" + e.StackTrace); } return(false); }