Beispiel #1
0
        public static async Task <LocalExperience> CreateAsync(MikiContext context, long ServerId, long userId)
        {
            LocalExperience experience = null;

            experience            = new LocalExperience();
            experience.ServerId   = ServerId;
            experience.UserId     = userId;
            experience.Experience = 0;

            experience = context.LocalExperience.Add(experience).Entity;
            await context.SaveChangesAsync();

            return(experience);
        }
Beispiel #2
0
        public static async Task <LocalExperience> CreateAsync(MikiContext context, long ServerId, long userId)
        {
            LocalExperience experience = null;

            experience                    = new LocalExperience();
            experience.ServerId           = ServerId;
            experience.UserId             = userId;
            experience.Experience         = 0;
            experience.LastExperienceTime = Utils.MinDbValue;

            experience = context.Experience.Add(experience);
            await context.SaveChangesAsync();

            return(experience);
        }
Beispiel #3
0
        public async Task <int> GetLocalRank(ulong guildId)
        {
            using (var context = new MikiContext())
            {
                LocalExperience l = await context.Experience.FindAsync(guildId.ToDbLong(), Id);

                if (l == null)
                {
                    return(-1);
                }

                int x = context.Database.SqlQuery <int>("Select COUNT(*) as rank from LocalExperience where LocalExperience.ServerId = @p0 AND LocalExperience.Experience >= @p1", guildId.ToDbLong(), l.Experience).First();
                return(x);
            }
        }
Beispiel #4
0
        public async Task <int> GetLocalRank(ulong guildId)
        {
            using (var context = new MikiContext())
            {
                LocalExperience l = await context.Experience.FindAsync(guildId.ToDbLong(), Id);

                if (l == null)
                {
                    return(-1);
                }

                long gId = guildId.ToDbLong();
                int  x   = context.Experience
                           .Where(e => e.ServerId == gId && e.Experience > l.Experience)
                           .Count();
                return(x);
            }
        }
Beispiel #5
0
        public static async Task <LocalExperience> CreateAsync(MikiContext context, long ServerId, IUser user)
        {
            long            userId     = user.Id.ToDbLong();
            LocalExperience experience = null;

            experience            = new LocalExperience();
            experience.ServerId   = ServerId;
            experience.UserId     = userId;
            experience.Experience = 0;

            experience = (await context.LocalExperience.AddAsync(experience)).Entity;

            if (await context.Users.FindAsync(userId) == null)
            {
                await User.CreateAsync(user);
            }

            await context.SaveChangesAsync();

            return(experience);
        }
Beispiel #6
0
        public static async Task <User> CreateAsync(IDiscordUser u)
        {
            using (var context = new MikiContext())
            {
                User user = new User()
                {
                    Id               = u.Id.ToDbLong(),
                    Currency         = 0,
                    AvatarUrl        = "default",
                    HeaderUrl        = "default",
                    LastDailyTime    = Utils.MinDbValue,
                    MarriageSlots    = 5,
                    Name             = u.Username,
                    Title            = "",
                    Total_Commands   = 0,
                    Total_Experience = 0,
                    Reputation       = 0
                };

                LocalExperience exp = new LocalExperience()
                {
                    Experience = 0,
                    ServerId   = u.Guild.Id.ToDbLong(),
                    UserId     = u.Id.ToDbLong(),
                };

                user.LocalExperience = new List <LocalExperience> {
                    exp
                };

                await context.Users.AddAsync(user);

                await context.LocalExperience.AddAsync(exp);

                await context.SaveChangesAsync();

                return(user);
            }
        }