Пример #1
0
        public static List <string> GetRoles <RolesEnum>(RolesEnum role)
            where RolesEnum : struct, IConvertible
        {
            ProjectRichardDBEntities context = new ProjectRichardDBEntities();

            return(context.RoleConformities
                   .AsNoTracking()
                   .Where(conformity => conformity.RealRole.Equals(role.ToString(), StringComparison.OrdinalIgnoreCase))
                   .Select(conformity => conformity.Role)
                   .ToList());
        }
Пример #2
0
        public static void AddRole <RolesEnum>(string role, RolesEnum realRole, long guildId)
            where RolesEnum : struct, IConvertible
        {
            ProjectRichardDBEntities context = new ProjectRichardDBEntities();

            var newRole = new RoleConformity()
            {
                Role = role.ToLower(), RealRole = realRole.ToString(), GuildId = guildId
            };

            context.RoleConformities.Add(newRole);
            context.SaveChanges();
        }
Пример #3
0
        public static RolesEnum GetRealRole <RolesEnum>(string role, long guildId)
            where RolesEnum : struct, IConvertible
        {
            ProjectRichardDBEntities context = new ProjectRichardDBEntities();

            var realRole = context.RoleConformities
                           .AsNoTracking()
                           .Where(conformity => (conformity.GuildId == guildId) &&
                                  (conformity.Role.Equals(role, StringComparison.OrdinalIgnoreCase)))
                           .Select(conformity => conformity.RealRole)
                           .FirstOrDefault();

            return(realRole == null ?  default(RolesEnum) :
                   (RolesEnum)Enum.Parse(typeof(RolesEnum), realRole));
        }
Пример #4
0
        public static bool RemoveRole(string roleForRemove, long guildId)
        {
            ProjectRichardDBEntities context = new ProjectRichardDBEntities();

            var roles = context.RoleConformities.
                        Where(conformity => conformity.Role.Equals(roleForRemove, StringComparison.OrdinalIgnoreCase) &&
                              conformity.GuildId == guildId);

            if (roles.Count() == 0)
            {
                return(false);
            }

            context.RoleConformities.RemoveRange(roles);
            context.SaveChanges();

            return(true);
        }
Пример #5
0
        private FilterService()
        {
            ProjectRichardDBEntities context = new ProjectRichardDBEntities();

            mRepository = new FilterRepository(context);
        }
        private AdvertisingService()
        {
            ProjectRichardDBEntities context = new ProjectRichardDBEntities();

            mRepository = new AdvertisingRepository(context);
        }
Пример #7
0
        private VoiceChannelService()
        {
            ProjectRichardDBEntities context = new ProjectRichardDBEntities();

            mRepository = new VoiceChannelRepository(context);
        }
        private ApplicationLogService()
        {
            ProjectRichardDBEntities context = new ProjectRichardDBEntities();

            mRepository = new ApplicationLogRepository(context);
        }
        private BlockedCommandService()
        {
            ProjectRichardDBEntities context = new ProjectRichardDBEntities();

            mRepository = new BlockedCommandRepository(context);
        }
Пример #10
0
        public static List <RoleConformity> GetRoleList()
        {
            ProjectRichardDBEntities context = new ProjectRichardDBEntities();

            return(context.RoleConformities.ToList());
        }
Пример #11
0
        private BlockedModuleService()
        {
            ProjectRichardDBEntities context = new ProjectRichardDBEntities();

            mRepository = new BlockedModuleRepository(context);
        }
Пример #12
0
        private SessionService()
        {
            ProjectRichardDBEntities context = new ProjectRichardDBEntities();

            mRepository = new SessionRepository(context);
        }
Пример #13
0
        private GuildService()
        {
            ProjectRichardDBEntities context = new ProjectRichardDBEntities();

            mRepository = new GuildRepository(context);
        }