public async Task SetChannelRoleAsync([Remainder] string input = "")
        {
            if (!StateChecker.IsGuildAdmin(Context))
            {
                await Context.Channel.SendMessageAsync(":x: You are not guild admin!");

                return;
            }

            if (StateChecker.IsPrivateMessage(Context))
            {
                await Context.Channel.SendMessageAsync(
                    ":x: Please use this command in the channel you wish to set the role for");
            }

            var roleHandler = new RoleHandler(Factory.GetDatabase());

            if (!roleHandler.IsValidRole(input))
            {
                await Context.Channel.SendMessageAsync($":x: *{input}* is not a valid channel role");

                return;
            }

            roleHandler.SetRoleForChannel(Context.Channel.Id, input);
            await Context.Channel.SendMessageAsync(
                $"This channel has now been set to the *{input.ToLower()}* role!");
        }
Example #2
0
        public NewsFeedViewModel(AspNetUser user)
        {
            var isAdmin = RoleHandler.isAdmin(user.Id);
            var groups  = user.Groups;
            ICollection <Post> posts = new List <Post>();

            //TODO TBD posts are shown twice
            foreach (var group in groups)
            {
                posts = posts.Union(group.Posts, new PostComparator()).ToList();
            }
            posts = posts.Union(user.Posts, new PostComparator()).ToList();
            FacebookDatabaseEntities entities = new FacebookDatabaseEntities();
            var friends = user.AspNetUsers;

            foreach (var friend in friends)
            {
                posts = posts.Union(friend.Posts.Where(x => groups.Where(y => y.group_id == x.group_id).Any() || x.group_id == null), new PostComparator()).ToList();
            }
            posts = posts.OrderByDescending(x => x.date).Distinct().ToList();

            this.posts = new List <PostViewModel>();
            foreach (var post in posts)
            {
                this.posts.Add(new PostViewModel(post, "Newsfeed", isAdmin));
            }
        }
Example #3
0
        private static async Task RulesRole(Cacheable <IUserMessage, ulong> arg1, ISocketMessageChannel arg2,
                                            SocketReaction arg3)
        {
            await RoleHandler.OnRulesReaction(arg1, arg2, arg3);

            await Task.CompletedTask;
        }
Example #4
0
        public GroupsViewModel(string selectedId, string userId)
        {
            var databaseEntities = new FacebookDatabaseEntities();
            var user             = databaseEntities.AspNetUsers.Find(userId);
            var groups           = user.Groups;

            myGroups = groups.Union(user.Groups1, new GroupComparator()).ToList();

            if (selectedId != null)
            {
                selectedGroup = databaseEntities.Groups.Find(int.Parse(selectedId));
            }
            else
            {
                selectedGroup = myGroups.FirstOrDefault();
            }

            //TO-DO add administrator permission
            if (selectedGroup != null)
            {
                newPost = new PostViewModel {
                    appLocation = "Groups", group_id = selectedGroup.group_id
                };
                if (selectedGroup.AspNetUsers.Contains(user))
                {
                    accesPermision = AccesPermision.readPermissions;
                }
                else
                {
                    accesPermision = AccesPermision.noPermission;
                }
            }
            isAdmin = RoleHandler.isAdmin(userId);
        }
Example #5
0
        public async Task ShowChannelRolesAsync()
        {
            if (!StateChecker.IsGuildAdmin(Context))
            {
                await Context.Channel.SendMessageAsync(":x: You are not guild admin!");

                return;
            }

            if (StateChecker.IsPrivateMessage(Context))
            {
                await Context.Channel.SendMessageAsync(
                    ":x: Please use this command in the guild you wish to see the roles for");
            }

            var roleHandler          = new RoleHandler(Factory.GetDatabase());
            var allGuildTextChannels = Context.Guild.TextChannels;
            var botUserId            = Context.Client.CurrentUser.Id;

            foreach (var guildChannel in allGuildTextChannels)
            {
                var users = guildChannel.Users;
                foreach (var user in users)
                {
                    if (user.Id == botUserId)
                    {
                        var role = roleHandler.GetRoleForChannel(guildChannel.Id);
                        await Context.Channel.SendMessageAsync($"{guildChannel.Name} : {role}");
                    }
                }
            }
        }
        public ActionResult CreateOrEditRole()
        {
            RoleResponse _response = new RoleResponse();

            if (Request.QueryString["id"] != null)
            {
                var request = new RoleRequest
                {
                    Data = new RoleModel
                    {
                        Id = long.Parse(Request.QueryString["id"].ToString())
                    }
                };

                RoleResponse resp   = new RoleHandler(_unitOfWork).GetDetail(request);
                RoleModel    _model = resp.Entity;
                ViewBag.Response   = _response;
                ViewBag.Organisasi = BindDropDownOrganization();
                ViewBag.ActionType = ClinicEnums.Action.Edit;
                return(View(_model));
            }
            else
            {
                ViewBag.Response   = _response;
                ViewBag.Organisasi = BindDropDownOrganization();
                ViewBag.ActionType = ClinicEnums.Action.Add;
                return(View());
            }
        }
        public ActionResult GetRoleData()
        {
            var _draw          = Request.Form.GetValues("draw").FirstOrDefault();
            var _start         = Request.Form.GetValues("start").FirstOrDefault();
            var _length        = Request.Form.GetValues("length").FirstOrDefault();
            var _sortColumn    = Request.Form.GetValues("columns[" + Request.Form.GetValues("order[0][column]").FirstOrDefault() + "][name]").FirstOrDefault();
            var _sortColumnDir = Request.Form.GetValues("order[0][dir]").FirstOrDefault();
            var _searchValue   = Request.Form.GetValues("search[value]").FirstOrDefault();

            int _pageSize = _length != null?Convert.ToInt32(_length) : 0;

            int _skip = _start != null?Convert.ToInt32(_start) : 0;

            var request = new RoleRequest
            {
                Draw          = _draw,
                SearchValue   = _searchValue,
                SortColumn    = _sortColumn,
                SortColumnDir = _sortColumnDir,
                PageSize      = _pageSize,
                Skip          = _skip
            };

            var response = new RoleHandler(_unitOfWork).GetListData(request);

            return(Json(new { data = response.Data, recordsFiltered = response.RecordsFiltered, recordsTotal = response.RecordsTotal, draw = response.Draw }, JsonRequestBehavior.AllowGet));
        }
Example #8
0
        protected override PeerBase CreatePeer(InitRequest initRequest)
        {
            ClientPeer curPeer = new ClientPeer(initRequest.Protocol, initRequest.PhotonPeer);

            log.Debug("One Peer is Created!");
            // 注册Handler
            RegisteHandler((byte)OperationCode.GetServer, new ServerPropertyHandler());
            RegisteHandler((byte)OperationCode.Login, new LoginHandler());
            RegisteHandler((byte)OperationCode.UserRegiste, new UserRegisteHandler());
            RoleHandler roleHander = new RoleHandler();

            RegisteHandler((byte)OperationCode.RoleHandler, roleHander);
            RegisteHandler((byte)OperationCode.CreateRole, roleHander);
            RegisteHandler((byte)OperationCode.ChooseRole, roleHander);

            TaskHandler taskHandler = new TaskHandler();

            RegisteHandler((byte)OperationCode.AddTask, taskHandler);
            RegisteHandler((byte)OperationCode.GetTask, taskHandler);
            RegisteHandler((byte)OperationCode.UpdateTask, taskHandler);

            RoleInfoHandler roleinfoHandler = new RoleInfoHandler();

            RegisteHandler((byte)OperationCode.AddRoleInfo, roleinfoHandler);
            RegisteHandler((byte)OperationCode.UpdateRoleInfo, roleinfoHandler);
            RegisteHandler((byte)OperationCode.GetRoleInfo, roleinfoHandler);

            RegisteHandler((byte)OperationCode.AddGoodsList, roleinfoHandler);
            RegisteHandler((byte)OperationCode.UpdateGoodsList, roleinfoHandler);
            RegisteHandler((byte)OperationCode.GetGoodsList, roleinfoHandler);

            RegisteHandler((byte)OperationCode.AddEquipList, roleinfoHandler);
            RegisteHandler((byte)OperationCode.UpdateEquipList, roleinfoHandler);
            RegisteHandler((byte)OperationCode.GetEquipList, roleinfoHandler);

            SkillHandler skillhandler = new SkillHandler();

            RegisteHandler((byte)OperationCode.GetSkill, skillhandler);
            RegisteHandler((byte)OperationCode.AddSkill, skillhandler);
            RegisteHandler((byte)OperationCode.UpdateSkill, skillhandler);

            BattleHandler battleHandler = new BattleHandler();

            RegisteHandler((byte)OperationCode.ForTeam, battleHandler);
            RegisteHandler((byte)OperationCode.CancelTeam, battleHandler);
            RegisteHandler((byte)OperationCode.SyncMove, battleHandler);
            RegisteHandler((byte)OperationCode.SyncMoveAnim, battleHandler);
            RegisteHandler((byte)OperationCode.RemoveTeamRole, battleHandler);
            RegisteHandler((byte)OperationCode.SyncMoveDir, battleHandler);

            MonsterHandler monsterHandler = new MonsterHandler();

            RegisteHandler((byte)OperationCode.CreateMonster, monsterHandler);
            RegisteHandler((byte)OperationCode.SyncMonsterMove, monsterHandler);
            return(curPeer);
        }
Example #9
0
        /// <summary>
        ///     Creates a new instance of this class.
        /// </summary>
        public Bot()
        {
            _config      = ConfigFactory.GenerateConfig();
            _persistence = SerializerFactory.GenerateSerializer();

            _commandHandler = new CommandHandler();
            _channelHandler = new ChannelHandler();
            _roleHandler    = new RoleHandler();
            _dblHandler     = new DblHandler();
        }
Example #10
0
        public void AddRoles()
        {
            Roles role = new Roles();

            role.Key      = "admin";
            role.Name     = "系统管理员";
            role.OwnerId  = Guid.NewGuid();
            role.Comments = "系统超级管理员";

            Assert.IsTrue(RoleHandler.AddRole(role));
        }
        //set department data from database
        public void setRegisterDepartment()
        {
            registerDepartmentcomboBox.Items.Add("--Select Department--");
            registerDepartmentcomboBox.SelectedIndex = 0;
            DBConnector dbC = new DBConnector();

            dbC.connect();
            RoleHandler roleHandler = new RoleHandler();
            List <Role> rolesList   = new List <Role>();

            rolesList = roleHandler.getAllRole(dbC.getConn());
            for (int i = 0; i < rolesList.Count; i++)
            {
                registerDepartmentcomboBox.Items.Add(rolesList[i].Position);
            }
        }
Example #12
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory, IServiceProvider serviceProvider)
        {
            loggerFactory.AddConsole(Configuration.GetSection("Logging"));
            loggerFactory.AddDebug();

            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
                app.UseDatabaseErrorPage();
                app.UseBrowserLink();
            }
            else
            {
                app.UseExceptionHandler("/Home/Error");
            }



            app.UseStaticFiles();

            app.UseIdentity();
            RoleHandler.AddRoles(serviceProvider, RoleHandler.Admin, RoleHandler.Post);

            // Add external authentication middleware below. To configure them please see http://go.microsoft.com/fwlink/?LinkID=532715
            string[] conf = File.ReadAllLines("secrets.txt");

            app.UseFacebookAuthentication(new FacebookOptions()
            {
                AppId      = conf[0],
                AppSecret  = conf[1],
                SaveTokens = true
            });

            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "default", // route
                    template: "{controller=Route}/{action=List}/{id?}");
                // Not sure if we'll need it though, nice as a test bench for now
                routes.MapRoute(
                    name: "home",
                    template: "{controller=Home}/{action=Index}/{id?}");
            });
        }
        public async Task ClearChannelRoleAsync()
        {
            if (!StateChecker.IsGuildAdmin(Context))
            {
                await Context.Channel.SendMessageAsync(":x: You are not guild admin!");

                return;
            }

            if (StateChecker.IsPrivateMessage(Context))
            {
                await Context.Channel.SendMessageAsync(
                    ":x: Please use this command in the channel you wish to clear the role for");
            }

            var roleHandler = new RoleHandler(Factory.GetDatabase());

            roleHandler.ClearRoleForChannel(Context.Channel.Id);
        }
Example #14
0
 public GameSocket(ISerializer serializer) : base(serializer)
 {
     _bagHandler           = new BagHandler(this);
     _battleHandler        = new BattleHandler(this);
     _dailyActivityHandler = new DailyActivityHandler(this);
     _equipHandler         = new EquipHandler(this);
     _itemHandler          = new ItemHandler(this);
     _messageHandler       = new MessageHandler(this);
     _npcHandler           = new NpcHandler(this);
     _petHandler           = new PetHandler(this);
     _petNewHandler        = new PetNewHandler(this);
     _playerHandler        = new PlayerHandler(this);
     _prepaidHandler       = new PrepaidHandler(this);
     _resourceHandler      = new ResourceHandler(this);
     _skillHandler         = new SkillHandler(this);
     _skillKeysHandler     = new SkillKeysHandler(this);
     _taskHandler          = new TaskHandler(this);
     _teamHandler          = new TeamHandler(this);
     _entryHandler         = new EntryHandler(this);
     _roleHandler          = new RoleHandler(this);
 }
        public ActionResult RolePrivilegeList()
        {
            RolePrivilegeModel rpmodel = new RolePrivilegeModel();

            if (Request.QueryString["roleid"] != null)
            {
                var reqOrg = new RoleRequest
                {
                    Data = new RoleModel
                    {
                        Id = Convert.ToInt64(Request.QueryString["roleid"].ToString())
                    }
                };

                var respOrg = new RoleResponse();
                respOrg          = new RoleHandler(_unitOfWork).GetDetail(reqOrg);
                rpmodel.RoleDesc = respOrg.Entity.RoleName;
                rpmodel.RoleID   = respOrg.Entity.Id;

                var _request = new RolePrivilegeRequest
                {
                    Data = new RolePrivilegeModel
                    {
                        RoleID = Convert.ToInt64(Request.QueryString["roleid"].ToString())
                    }
                };
                //get Privilege Ids for organization
                var selPrivileges = new RolePrivilegeHandler(_unitOfWork, _context).GetListData(_request);
                if (selPrivileges.Entity.PrivilegeIDs != null && selPrivileges.Entity.PrivilegeIDs.Count > 0)
                {
                    rpmodel.PrivilegeIDs = selPrivileges.Entity.PrivilegeIDs;
                }
            }

            return(View(rpmodel));
        }
 public bool InActiveRole(int roleId, string ownerId)
 {
     return(RoleHandler.InActiveRole(roleId, Guid.Parse(ownerId)));
 }
Example #17
0
    public async Task MainAsync()
    {
        //initialize and connect client
        _client      = new DiscordSocketClient();
        _client.Log += Log;

        //get config
        _config = new Config();
        String json_str;

        try {
            json_str = File.ReadAllText("data/config.json");
            _config  = JsonSerializer.Deserialize <Config>(json_str);
        } catch (Exception e) {
            if (e is FileNotFoundException)
            {
                Console.WriteLine("ERROR: data/config.json not found. Creating new config.json file. Please set BotToken field.");
                File.WriteAllText("data/config.json", JsonSerializer.Serialize(_config));
            }
            else if (e is JsonException)
            {
                Console.WriteLine("ERROR: data/config.json: " + e.Message);
            }
            else
            {
                Console.WriteLine("ERROR: exception thrown when trying to load data/config.json: ");
                throw;
            }
            return;
        }

        if (_config.CommandEnabled || _config.RoleEnabled)
        {
            Console.WriteLine("Setting up handler(s) in 4 seconds.");
        }

        //login using generated token
        try {
            await _client.LoginAsync(
                TokenType.Bot,
                _config.BotToken
                );
        } catch {
            Console.WriteLine("ERROR: could not log in. Ensure the BotToken field in data/config.json is valid.");
            return;
        }

        //begin running and wait 4 seconds to allow client to connect
        await _client.StartAsync();

        if (_config.CommandEnabled || _config.RoleEnabled)
        {
            await Task.Delay(4000);
        }

        //set up command handler
        if (_config.CommandEnabled)
        {
            _commandhandler = new CommandHandler(_config);
            if (_commandhandler.LoadCommands() != 0)
            {
                Console.WriteLine("WARN: could not initialize command handler.");
                _commandhandler = null;
            }
            else
            {
                //hook command handler to message received event
                _client.MessageReceived += HandleMessageAsync;
                Console.WriteLine("Command handler ready.");
            }
        }

        //set up role handler
        if (_config.RoleEnabled)
        {
            SocketGuild       foundguild   = null;
            SocketTextChannel foundchannel = null;

            //try to get guilds from client 3 times
            var guilds = _client.Guilds;
            int i      = 0;
            while (guilds.Count <= 0 && i < 2)
            {
                Console.WriteLine("WARN: retrieved 0 guilds from client. Retrying in 4 seconds.");
                await Task.Delay(4000);

                guilds = _client.Guilds;
                i     += 1;
            }

            if (guilds.Count > 0)
            {
                //find guild in config
                foreach (SocketGuild guild in guilds)
                {
                    if (guild.Name == _config.RoleGuild)
                    {
                        foundguild = guild;
                        break;
                    }
                }
                if (foundguild != null)
                {
                    //find channel in config
                    var channels = foundguild.TextChannels;
                    foreach (SocketTextChannel channel in channels)
                    {
                        if (channel.Name == _config.RoleChannel)
                        {
                            foundchannel = channel;
                            break;
                        }
                    }
                }
                //try to initialize role handler
                if (foundguild != null && foundchannel != null)
                {
                    _rolehandler = new RoleHandler(foundguild, foundchannel);
                    if ((await _rolehandler.LoadRoles()) != 0)
                    {
                        Console.WriteLine("WARN: could not initialize role handler.");
                        _rolehandler = null;
                    }
                    else
                    {
                        //give command handler reference to role handler's load method on success
                        _commandhandler.SetLoadRolesFn(_rolehandler.LoadRoles);

                        //hook reaction handler to reaction events
                        _client.ReactionAdded   += HandleReactionAddedAsync;
                        _client.ReactionRemoved += HandleReactionRemovedAsync;
                        Console.WriteLine("Role handler ready.");
                    }
                }
                else
                {
                    Console.WriteLine("WARN: config.json: could not find guild or channel specified in configuration for role handler. Either they do not exist, or client did not connect within 5 seconds.");
                    Console.WriteLine("WARN: could not initialize role handler.");
                }
            }
            else
            {
                Console.WriteLine("WARN: retrieved 0 guilds from client while trying to initialize role handler.");
                Console.WriteLine("WARN: could not initialize role handler.");
            }
        }

        //set up join handler
        if (_config.JoinEnabled)
        {
            SocketGuild       foundguild   = null;
            SocketTextChannel foundchannel = null;

            //try to get guilds from client 3 times
            var guilds = _client.Guilds;
            int i      = 0;
            while (guilds.Count <= 0 && i < 2)
            {
                Console.WriteLine("WARN: retrieved 0 guilds from client. Retrying in 4 seconds.");
                await Task.Delay(4000);

                guilds = _client.Guilds;
                i     += 1;
            }

            if (guilds.Count > 0)
            {
                //find guild in config
                foreach (SocketGuild guild in guilds)
                {
                    if (guild.Name == _config.JoinGuild)
                    {
                        foundguild = guild;
                        break;
                    }
                }
                if (foundguild != null)
                {
                    //find channel in config
                    var channels = foundguild.TextChannels;
                    foreach (SocketTextChannel channel in channels)
                    {
                        if (channel.Name == _config.JoinChannel)
                        {
                            foundchannel = channel;
                            break;
                        }
                    }
                }
                //try to initialize join handler
                if (foundguild != null && foundchannel != null)
                {
                    _joinhandler = new JoinHandler(foundguild, foundchannel);
                    if ((await _joinhandler.LoadJoin()) != 0)
                    {
                        Console.WriteLine("WARN: could not initialize join handler.");
                        _joinhandler = null;
                    }
                    else
                    {
                        //give command handler reference to join handler's load method on success
                        _commandhandler.SetLoadJoinFn(_joinhandler.LoadJoin);

                        //hook reaction handler to join event
                        _client.UserJoined += HandleUserJoinedAsync;
                        Console.WriteLine("Join handler ready.");
                    }
                }
                else
                {
                    Console.WriteLine("WARN: config.json: could not find guild or channel specified in configuration for join handler. Either they do not exist, or client did not connect within 5 seconds.");
                    Console.WriteLine("WARN: could not initialize join handler.");
                }
            }
            else
            {
                Console.WriteLine("WARN: retrieved 0 guilds from client while trying to initialize join handler.");
                Console.WriteLine("WARN: could not initialize join handler.");
            }
        }

        //delay infinitely
        await Task.Delay(-1);
    }
Example #18
0
        public static bool IsGeneralChannel(SocketCommandContext context)
        {
            var roleHandler = new RoleHandler(Factory.GetDatabase());

            return(roleHandler.GetRoleForChannel(context.Channel.Id) == "general");
        }
Example #19
0
 public RolesController(RoleHandler handler, IStringLocalizer <RolesController> localizer)
 {
     _handler   = handler;
     _localizer = localizer;;
 }
Example #20
0
 public GameSocket(ISerializer serializer) : base(serializer)
 {
     _achievementHandler       = new AchievementHandler(this);
     _activityHandler          = new ActivityHandler(this);
     _activityFavorHandler     = new ActivityFavorHandler(this);
     _amuletHandler            = new AmuletHandler(this);
     _arenaHandler             = new ArenaHandler(this);
     _attendanceHandler        = new AttendanceHandler(this);
     _bagHandler               = new BagHandler(this);
     _battleHandler            = new BattleHandler(this);
     _cardHandler              = new CardHandler(this);
     _consignmentLineHandler   = new ConsignmentLineHandler(this);
     _crossServerHandler       = new CrossServerHandler(this);
     _dailyActivityHandler     = new DailyActivityHandler(this);
     _demonTowerHandler        = new DemonTowerHandler(this);
     _equipHandler             = new EquipHandler(this);
     _exchangeHandler          = new ExchangeHandler(this);
     _fashionHandler           = new FashionHandler(this);
     _fightLevelHandler        = new FightLevelHandler(this);
     _fleeHandler              = new FleeHandler(this);
     _friendHandler            = new FriendHandler(this);
     _functionHandler          = new FunctionHandler(this);
     _functionOpenHandler      = new FunctionOpenHandler(this);
     _giftOnlineHandler        = new GiftOnlineHandler(this);
     _goddessHandler           = new GoddessHandler(this);
     _guildBlessHandler        = new GuildBlessHandler(this);
     _guildBossHandler         = new GuildBossHandler(this);
     _guildDepotHandler        = new GuildDepotHandler(this);
     _guildHandler             = new GuildHandler(this);
     _guildShopHandler         = new GuildShopHandler(this);
     _guildTechHandler         = new GuildTechHandler(this);
     _hookSetHandler           = new HookSetHandler(this);
     _interactHandler          = new InteractHandler(this);
     _intergalMallHandler      = new IntergalMallHandler(this);
     _itemHandler              = new ItemHandler(this);
     _leaderBoardHandler       = new LeaderBoardHandler(this);
     _limitTimeActivityHandler = new LimitTimeActivityHandler(this);
     _mailHandler              = new MailHandler(this);
     _mapHandler               = new MapHandler(this);
     _masteryHandler           = new MasteryHandler(this);
     _medalHandler             = new MedalHandler(this);
     _messageHandler           = new MessageHandler(this);
     _mountHandler             = new MountHandler(this);
     _npcHandler               = new NpcHandler(this);
     _offlineAwardHandler      = new OfflineAwardHandler(this);
     _onlineGiftHandler        = new OnlineGiftHandler(this);
     _payGiftHandler           = new PayGiftHandler(this);
     _petHandler               = new PetHandler(this);
     _petNewHandler            = new PetNewHandler(this);
     _playerHandler            = new PlayerHandler(this);
     _prepaidHandler           = new PrepaidHandler(this);
     _rankHandler              = new RankHandler(this);
     _resourceDungeonHandler   = new ResourceDungeonHandler(this);
     _resourceHandler          = new ResourceHandler(this);
     _rewardHandler            = new RewardHandler(this);
     _saleHandler              = new SaleHandler(this);
     _shopMallHandler          = new ShopMallHandler(this);
     _skillHandler             = new SkillHandler(this);
     _skillKeysHandler         = new SkillKeysHandler(this);
     _soloHandler              = new SoloHandler(this);
     _stealHandler             = new StealHandler(this);
     _sysSetHandler            = new SysSetHandler(this);
     _taskHandler              = new TaskHandler(this);
     _teamHandler              = new TeamHandler(this);
     _tradeHandler             = new TradeHandler(this);
     _treasureHandler          = new TreasureHandler(this);
     _upLevelHandler           = new UpLevelHandler(this);
     _vipHandler               = new VipHandler(this);
     _vitalityHandler          = new VitalityHandler(this);
     _wingHandler              = new WingHandler(this);
     _activityRevelryHandler   = new ActivityRevelryHandler(this);
     _auctionHandler           = new AuctionHandler(this);
     _chatHandler              = new ChatHandler(this);
     _daoYouHandler            = new DaoYouHandler(this);
     _entryHandler             = new EntryHandler(this);
     _roleHandler              = new RoleHandler(this);
     _farmHandler              = new FarmHandler(this);
     _five2FiveHandler         = new Five2FiveHandler(this);
     _guildManagerHandler      = new GuildManagerHandler(this);
     _xianYuanHandler          = new XianYuanHandler(this);
 }
Example #21
0
 public static Role getRoleByName(String roleName)
 {
     return(RoleHandler.getRoleByName(roleName));
 }
Example #22
0
 public static Role getRoleByID(int roleID)
 {
     return(RoleHandler.getRoleByID(roleID));
 }
Example #23
0
 public static List <Role> getAllRole()
 {
     return(RoleHandler.getAllRole());
 }
Example #24
0
        public ActionResult Show(string id)
        {
            var databaseEntities = new FacebookDatabaseEntities();

            if (databaseEntities.AspNetUsers.Find(id) == null)
            {
                return(View("Profile", null));
            }

            var iAmaVisitor = true;

            if (User.Identity.GetUserId() == id)
            {
                iAmaVisitor = false;
            }
            var isAdmin = false;

            if (User.Identity.GetUserId() != null)
            {
                isAdmin = RoleHandler.isAdmin(User.Identity.GetUserId());
            }

            var     loggedUser = databaseEntities.AspNetUsers.Find(User.Identity.GetUserId());
            Profile profile    = databaseEntities.Profiles.Find(id);

            if (profile == null)
            {
                return(View("AddProfile", new ProfileViewModel()));
            }
            else
            {
                //TO-DO: add properties to ProfileViewModel like : albums, posts and personal informations and show them into view.
                var aspNetUser = databaseEntities.AspNetUsers.Find(id);
                var posts      = aspNetUser.Posts;
                List <PostViewModel> userPosts = new List <PostViewModel>();
                foreach (var post in posts)
                {
                    userPosts.Add(new PostViewModel(post, "Profile", isAdmin));
                }
                List <Album>          albums     = databaseEntities.Albums.Where(x => x.user_id == id).ToList();
                List <AlbumViewModel> userAlbums = new List <AlbumViewModel>();
                foreach (Album album in albums)
                {
                    userAlbums.Add(new AlbumViewModel(album.name, "Profile", album.album_id, userPosts, id));
                }

                List <AspNetUser> friends         = aspNetUser.AspNetUsers.ToList();
                List <Profile>    profiles        = databaseEntities.Profiles.ToList();
                List <Profile>    friendsProfiles = (from aspUser in friends
                                                     join friendProfile in profiles on aspUser.Id equals friendProfile.Id
                                                     select friendProfile).ToList();
                List <FriendViewModel> friendsList = new List <FriendViewModel>();
                foreach (Profile friend in friendsProfiles)
                {
                    friendsList.Add(new FriendViewModel(friend.Id, friend.Albums.Where(x => x.name == "ProfileAlbum").FirstOrDefault().Pictures.OrderByDescending(x => x.date).FirstOrDefault().path, friend.firstname + friend.lastname));
                }
                var profileViewModel = new ProfileViewModel(profile, userAlbums, userPosts, friendsList);
                profileViewModel.iAmaVisitor = iAmaVisitor;
                profileViewModel.isAdmin     = isAdmin;
                if (iAmaVisitor)
                {
                    var myID = User.Identity.GetUserId();
                    profileViewModel.profileVisitorID = myID;
                    if (friendsProfiles.Select(x => x.Id).ToList().Contains(myID))
                    {
                        profileViewModel.relationshipStatus = FriendshipStatus.friends;
                    }
                    else
                    {
                        profileViewModel.relationshipStatus = MessageHandler.GetFriendRequestStatus(User.Identity.GetUserId(), id);
                    }
                }

                if (profile.privacy == 1)
                {
                    if (profile.AspNetUser.Id != User.Identity.GetUserId() && !aspNetUser.AspNetUsers.Where(x => x.Id == User.Identity.GetUserId()).Any())
                    {
                        profileViewModel.privacy = true;
                    }
                }

                return(View("Profile", profileViewModel));
            }
        }
 public bool AddRole([FromBody] Roles role)
 {
     return(RoleHandler.AddRole(role));
 }
 public bool UpdateRole([FromBody] Roles role)
 {
     return(RoleHandler.UpdateRoleInfo(role));
 }
        public JArray ListAllRoles()
        {
            DataSet ds = RoleHandler.ListAllRoles();

            return(CommonHandler.TransferArrayFromDS(ds));
        }