Esempio n. 1
0
        private static void DatabasePersonalInit(CommandEventArgs e)
        {
            using (var context = new discordbotEntities_draw())
            {
                string str    = e.Server.Id.ToString();
                var    entity = context.personal.Where(input => (input.userid == e.User.NicknameMention && input.channal == str)).FirstOrDefault();

                if (entity != null)
                {
                    entity.username       = e.User.Name;
                    entity.SSR            = 0;
                    entity.SR             = 0;
                    entity.R              = 0;
                    entity.totaldrawcount = 0;
                }
                else
                {
                    context.personal.Add(new personal
                    {
                        userid         = e.User.NicknameMention,
                        username       = e.User.Name,
                        channal        = e.Server.Id.ToString(),
                        SSR            = 0,
                        SR             = 0,
                        R              = 0,
                        totaldrawcount = 0
                    });
                }
                context.SaveChanges();
            }
        }
Esempio n. 2
0
 private static void DatabasePersonalUpdate(CommandEventArgs e, int countSSR, int countSR, int countR, int count)
 {
     using (var context = new discordbotEntities_draw())
     {
         string str    = e.Server.Id.ToString();
         var    entity = context.personal.Where(input => (input.userid == e.User.NicknameMention && input.channal == str)).FirstOrDefault();
         if (entity != null)
         {
             entity.username        = e.User.Name;
             entity.SSR            += countSSR;
             entity.SR             += countSR;
             entity.R              += countR;
             entity.totaldrawcount += count;
         }
         context.SaveChanges();
     }
 }