Ejemplo n.º 1
0
        public void CreateFromAPI(RoleCreate roleCreate)
        {
            RoleRepository roleRepository = new RoleRepository();

            roleRepository.Name = roleCreate.Name;
            this.roleStoreRepository.Create(roleRepository);
        }
Ejemplo n.º 2
0
        public async Task <Role> Create(RoleCreate roleIn)
        {
            var role = Role.FromCreate(roleIn);
            await _roles.InsertOneAsync(role);

            return(role);
        }
Ejemplo n.º 3
0
        public bool CreateRole(RoleCreate model)
        {
            var            identr = new IdentityRole(model.RoleName);
            IdentityResult result = roleManager.Create(identr);

            // Just in case...
            model.RoleID = Guid.Parse(identr.Id);
            Context.SaveChanges();
            return(result.Succeeded);
        }
Ejemplo n.º 4
0
        public void RoleCreate_Template_Test()
        {
            var template = new RoleCreate(new SmartAppInfo {
                Id = ApplicationId
            });
            var output = template.TransformText();

            Assert.NotNull(output);
            Assert.NotEmpty(output);
            Assert.Contains($"@model {ApplicationId}.Backend.Models.RoleViewModel", output);
        }
Ejemplo n.º 5
0
        public ActionResult CreateAndAssignFunc(Guid userID, string roleName)
        {
            var svc   = CreateRoleService();
            var usvc  = CreateUserRoleService();
            var model = new RoleCreate {
                RoleName = roleName
            };
            var b = svc.CreateRole(model);

            AbstractService.Context.SaveChanges();
            usvc.AssignRole(userID, svc.GetRoleById(model.RoleID));
            return(RedirectToAction("ListUsers", "Account", new { }));
        }
Ejemplo n.º 6
0
    public void RefreshSkillInfo()
    {
        RoleCreate roleCreate = DataReader <RoleCreate> .Get(this.profession);

        if (roleCreate == null)
        {
            return;
        }
        for (int i = 0; i < this.m_skills.get_Count(); i++)
        {
            int key = 0;
            if (i == 0)
            {
                key = roleCreate.skill1.get_Item(0).value;
            }
            else if (i == 1)
            {
                key = roleCreate.skill2.get_Item(0).value;
            }
            else if (i == 2)
            {
                key = roleCreate.skill3.get_Item(0).value;
            }
            Skill skill = DataReader <Skill> .Get(key);

            if (skill == null)
            {
                this.m_skills.get_Item(i).get_gameObject().SetActive(false);
            }
            else
            {
                this.m_skills.get_Item(i).get_gameObject().SetActive(true);
                this.m_skills.get_Item(i).m_info = this;
                this.m_skills.get_Item(i).SetIcon(GameDataUtils.GetIcon(skill.icon));
                if (skill.describeId > 0)
                {
                    this.m_skills.get_Item(i).SetDesc(this.m_lblSkillDesc, GameDataUtils.GetChineseContent(skill.describeId, false));
                }
                else
                {
                    this.m_skills.get_Item(i).SetDesc(this.m_lblSkillDesc, string.Empty);
                }
                if (i == 0)
                {
                    this.m_skills.get_Item(i).SetSelectBtnState(true);
                    this.m_skills.get_Item(i).SetDesc();
                }
            }
        }
    }
Ejemplo n.º 7
0
        public ActionResult Create(RoleCreate model, int n)
        {
            var svc = CreateRoleService();

            if (!ModelState.IsValid)
            {
                return(View(model));
            }
            if (svc.CreateRole(model))
            {
                TempData["SaveResult"] = $"The Role \"{model.RoleName}\" was created successfuly.";
                return(RedirectToAction("Index"));
            }
            return(View(model));
        }
Ejemplo n.º 8
0
        public async Task <bool> CreateRole(RoleCreate request)
        {
            IdentityRole identityRole = new IdentityRole
            {
                Name = request.RoleName
            };

            IdentityResult result = await _roleManager.CreateAsync(identityRole);

            if (result.Succeeded)
            {
                return(true);
            }

            return(false);
        }
Ejemplo n.º 9
0
    IEnumerator CreateRolePhysics(PlayerBase player, RoleCreate roleCreate)
    {
        if (player != null)
        {
            IEnumerator itor = player.CreatePhysics(false, PhysicsType.Player);
            while (itor.MoveNext())
            {
                yield return(null);
            }

            player.CreateUIRoleCamera(roleCreate.m_ShowRectTL.position, roleCreate.m_ShowRectBR.position, m_ShowCamera, roleCreate.m_Layer);


            player.CurrentStyle = PlayerStyleType.Create;
        }
    }
Ejemplo n.º 10
0
        public ActionResult CreateRole(RoleCreate model)
        {
            using (var client = new HttpClient())
            {
                client.BaseAddress = new Uri("https://localhost:44320/api/");
                string token = DeserializeToken();
                client.DefaultRequestHeaders.Clear();
                client.DefaultRequestHeaders.Add("Authorization", "Bearer " + token);

                var postTask = client.PostAsJsonAsync <RoleCreate>("Admin/AddRole", model);
                postTask.Wait();

                var result = postTask.Result;
                if (result.IsSuccessStatusCode)
                {
                    return(RedirectToAction("GetRoles"));
                }
                ModelState.AddModelError(string.Empty, result.Content.ReadAsStringAsync().Result);
            }
            return(View(model));
        }
Ejemplo n.º 11
0
        public async Task <IHttpActionResult> CreateRole(RoleCreate model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            IdentityRole identityRole = new IdentityRole
            {
                Name = model.RoleName
            };

            IdentityResult result = await RoleManager.CreateAsync(identityRole);

            if (!result.Succeeded)
            {
                return(GetErrorResult(result));
            }

            return(Ok());
        }
    public void EnterChangeCareerInstance(int profession)
    {
        this.IsWinWithChange = false;
        this.IsQuit          = false;
        this.dst_profession  = profession;
        RoleCreate roleCreate = DataReader <RoleCreate> .Get(profession);

        if (roleCreate == null)
        {
            return;
        }
        FuBenJiChuPeiZhi fuBenJiChuPeiZhi = DataReader <FuBenJiChuPeiZhi> .Get(ChangeCareerInstance.ChangeCareerInstanceDataID);

        if (fuBenJiChuPeiZhi == null)
        {
            return;
        }
        ChangeCareerManager.Instance.SendInChallengeNty();
        InstanceManager.ChangeInstanceManager(ChangeCareerInstance.Instance, false);
        InstanceManager.SimulateEnterField(10, null);
        InstanceManager.SimulateSwicthMap(ChangeCareerInstance.Instance.InstanceData.scene, LocalInstanceHandler.Instance.CreateSelfInfo(fuBenJiChuPeiZhi.type, fuBenJiChuPeiZhi.id, fuBenJiChuPeiZhi.scene, profession, roleCreate.modle, this.GetDecorations(profession), null, this.GetBattleSkillInfos(profession)), null, 0);
    }
Ejemplo n.º 13
0
        public async Task <IActionResult> CreateRole(RoleCreate request)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    var userRoleRequest = await _adminService.CreateRole(request);

                    if (userRoleRequest = !false)
                    {
                        return(RedirectToAction(nameof(Index)));
                    }
                }
                ;

                throw new Exception();
            }
            catch (Exception e)
            {
                ModelState.AddModelError("", e.Message);
                return(View(request));
            }
        }
Ejemplo n.º 14
0
    private int GetPriority(Transform boss)
    {
        ActorParent component = boss.GetComponent <ActorParent>();
        int         typeID    = component.GetEntity().TypeID;
        int         result    = -1;

        if (component as ActorMonster)
        {
            Monster monster = DataReader <Monster> .Get(typeID);

            result = monster.cameraLock;
        }
        else if (component as ActorPlayer)
        {
            RoleCreate roleCreate = DataReader <RoleCreate> .Get(typeID);

            result = roleCreate.cameraLock;
        }
        else
        {
            Debug.Log("<color=red>Error:</color>GetPriority=NEITHER Monster NOR Player " + component);
        }
        return(result);
    }
Ejemplo n.º 15
0
        public ActionResult CreateRole()
        {
            var model = new RoleCreate();

            return(View(model));
        }
    public List <BattleSkillInfo> GetBattleSkillInfos(int profession)
    {
        List <BattleSkillInfo> list       = new List <BattleSkillInfo>();
        RoleCreate             roleCreate = DataReader <RoleCreate> .Get(profession);

        if (roleCreate == null)
        {
            return(null);
        }
        RoleCreate roleCreate2 = DataReader <RoleCreate> .Get(EntityWorld.Instance.EntSelf.TypeID);

        if (roleCreate2 == null)
        {
            return(null);
        }
        list.Clear();
        if (roleCreate.normalAttack.get_Count() > 0)
        {
            list.Add(new BattleSkillInfo
            {
                skillIdx = roleCreate.normalAttack.get_Item(0).key,
                skillId  = roleCreate.normalAttack.get_Item(0).value
            });
        }
        if (roleCreate.attack1.get_Count() > 0)
        {
            list.Add(new BattleSkillInfo
            {
                skillIdx = roleCreate.attack1.get_Item(0).key,
                skillId  = roleCreate.attack1.get_Item(0).value
            });
        }
        if (roleCreate.attack2.get_Count() > 0)
        {
            list.Add(new BattleSkillInfo
            {
                skillIdx = roleCreate.attack2.get_Item(0).key,
                skillId  = roleCreate.attack2.get_Item(0).value
            });
        }
        if (roleCreate.attack3.get_Count() > 0)
        {
            list.Add(new BattleSkillInfo
            {
                skillIdx = roleCreate.attack3.get_Item(0).key,
                skillId  = roleCreate.attack3.get_Item(0).value
            });
        }
        if (roleCreate.attack4.get_Count() > 0)
        {
            list.Add(new BattleSkillInfo
            {
                skillIdx = roleCreate.attack4.get_Item(0).key,
                skillId  = roleCreate.attack4.get_Item(0).value
            });
        }
        if (roleCreate.skill1.get_Count() > 0 && roleCreate2.skill1.get_Count() > 0)
        {
            list.Add(new BattleSkillInfo
            {
                skillIdx = 11,
                skillId  = roleCreate.skill1.get_Item(0).value,
                skillLv  = Mathf.Max(1, SkillUIManager.Instance.GetSkillLvByID(roleCreate.skill1.get_Item(0).value))
            });
        }
        if (roleCreate.skill2.get_Count() > 0 && roleCreate2.skill2.get_Count() > 0)
        {
            list.Add(new BattleSkillInfo
            {
                skillIdx = 12,
                skillId  = roleCreate.skill2.get_Item(0).value,
                skillLv  = Mathf.Max(1, SkillUIManager.Instance.GetSkillLvByID(roleCreate.skill2.get_Item(0).value))
            });
        }
        if (roleCreate.skill3.get_Count() > 0 && roleCreate2.skill3.get_Count() > 0)
        {
            list.Add(new BattleSkillInfo
            {
                skillIdx = 13,
                skillId  = roleCreate.skill3.get_Item(0).value,
                skillLv  = Mathf.Max(1, SkillUIManager.Instance.GetSkillLvByID(roleCreate.skill3.get_Item(0).value))
            });
        }
        if (roleCreate.roll.get_Count() > 0)
        {
            list.Add(new BattleSkillInfo
            {
                skillIdx = roleCreate.roll.get_Item(0).key,
                skillId  = roleCreate.roll.get_Item(0).value
            });
        }
        if (roleCreate.roll2.get_Count() > 0)
        {
            list.Add(new BattleSkillInfo
            {
                skillIdx = roleCreate.roll2.get_Item(0).key,
                skillId  = roleCreate.roll2.get_Item(0).value
            });
        }
        return(list);
    }
Ejemplo n.º 17
0
        private void TransformViewsRoleAdminRoleCreate(SmartAppInfo manifest)
        {
            var template = new RoleCreate(manifest);

            _writingService.WriteFile(Path.Combine(_context.BasePath, template.OutputPath), template.TransformText());
        }
Ejemplo n.º 18
0
        public async Task <ActionResult <Role> > Create([FromHeader] string authToken, RoleCreate role)
        {
            if (!await _authenticationService.CheckAccess(authToken, "roleMgr"))
            {
                return(Unauthorized());
            }

            Role created = await _roleService.Create(role);

            await _logService.Create(new Log(
                                         null,
                                         AuthenticationHelpers.GetUserIdFromToken(authToken),
                                         DateTime.UtcNow,
                                         "Document created.",
                                         "auth.roles",
                                         created.Id,
                                         JsonSerializer.Serialize(created)
                                         ));

            return(Ok(role));
        }
Ejemplo n.º 19
0
        public void RoleCreate_Template_NullParameter_Test()
        {
            var template = new RoleCreate(null);

            Assert.Throws <NullReferenceException>(() => template.TransformText());
        }
Ejemplo n.º 20
0
        //TODO: Typing Start
        //TODO: Integrations
        //TODO: User Updates
        //TODO: Voice Chat

        private void GatewayMessageHandler(string eventName, string payload)
        {
            _Logger?.Debug($"{eventName} - {payload}");

            var eventValue = (Events)Enum.Parse(typeof(Events), eventName);

            var eventPayload = JObject.Parse(payload);

            switch (eventValue)
            {
            case Events.READY:
            {
                var guilds = eventPayload["guilds"] as JArray;

                foreach (var guild in guilds)
                {
                    var g = new Guild {
                        Id = guild["id"].ToString(), Unavailable = guild["unavailable"].ToObject <bool>()
                    };

                    Guilds.Add(g.Id, g);
                }

                break;
            }

            case Events.GUILD_CREATE:
            {
                Guild g = null;
                if (Guilds.ContainsKey(eventPayload["id"].ToString()))
                {
                    g = Guilds[eventPayload["id"].ToString()];
                }
                else
                {
                    g = new Guild()
                    {
                        Id = eventPayload["id"].ToString()
                    };
                    Guilds.Add(g.Id, g);
                }

                JsonConvert.PopulateObject(payload, g);

                foreach (var channel in g.Channels)
                {
                    if (!Channels.ContainsKey(channel.Key))
                    {
                        Channels.Add(channel.Key, channel.Value);
                    }

                    channel.Value.Guild_Id = g.Id;
                    channel.Value.Guild    = g;
                }

                foreach (var member in g.Members)
                {
                    if (!Users.ContainsKey(member.Key))
                    {
                        Users.Add(member.Key, member.Value.User);
                    }
                    else if (member.Value.User != Users[member.Key])
                    {
                        member.Value.User = Users[member.Key];
                    }

                    member.Value.Guild = g;
                }

                foreach (var presence in g.Presences.Values)
                {
                    presence.User = Users[presence.User.Id];
                }

                g.UpdateAllUserPermissions();

                GuildCreated?.Invoke(g);
                break;
            }

            case Events.GUILD_UPDATE:
            {
                var g = Guilds[eventPayload["id"].ToString()];

                // TODO: Double check that this is the correct behavior.
                JsonConvert.PopulateObject(payload, g);

                GuildUpdated?.Invoke(g);
                break;
            }

            case Events.GUILD_DELETE:
            {
                var g = Guilds[eventPayload["id"].ToString()];
                Guilds.Remove(eventPayload["id"].ToString());

                GuildDeleted?.Invoke(g);
                break;
            }

            case Events.CHANNEL_CREATE:
            {
                var c = eventPayload.ToObject <GuildChannel>();
                var g = Guilds[c.Guild_Id];

                c.Guild = g;
                g.Channels.Add(c.Id, c);
                Channels.Add(c.Id, c);

                ChannelCreate?.Invoke(g, c);
                break;
            }

            case Events.CHANNEL_UPDATE:
            {
                var g = Guilds[eventPayload["guild_id"].ToString()];
                var c = g.Channels[eventPayload["id"].ToString()];

                JsonConvert.PopulateObject(payload, c);

                ChannelUpdate?.Invoke(g, c);
                break;
            }

            case Events.CHANNEL_DELETE:
            {
                var g = Guilds[eventPayload["guild_id"].ToString()];
                var c = g.Channels[eventPayload["id"].ToString()];

                g.Channels.Remove(c.Id);
                Channels.Remove(c.Id);

                ChannelDelete?.Invoke(g, c);
                break;
            }

            case Events.GUILD_BAN_ADD:
            {
                // TODO: User knows about bans
                var g = Guilds[eventPayload["guild_id"].ToString()];
                var m = g.Members[eventPayload["id"].ToString()];

                Users[m.User.Id].Guilds.Remove(g);
                g.Members.Remove(m.User.Id);

                BanAdd?.Invoke(g, m.User);
                break;
            }

            case Events.GUILD_BAN_REMOVE:
            {
                var g = Guilds[eventPayload["guild_id"].ToString()];

                BanRemove?.Invoke(g, eventPayload.ToObject <DiscordUser>());
                break;
            }

            case Events.GUILD_EMOJIS_UPDATE:
            {
                var g = Guilds[eventPayload["guild_id"].ToString()];

                g.Emojis.Clear();

                JsonConvert.PopulateObject(payload, g);

                EmojiUpdate?.Invoke(g, eventPayload["emojis"].ToObject <List <Guild.Emoji> >());
                break;
            }

            case Events.GUILD_MEMBER_ADD:
            {
                var g = Guilds[eventPayload["guild_id"].ToString()];
                var m = eventPayload.ToObject <GuildMember>();

                if (!Users.ContainsKey(m.User.Id))
                {
                    Users.Add(m.User.Id, m.User);
                }
                else
                {
                    m.User = Users[m.User.Id];
                }

                g.Members.Add(m.User.Id, m);
                m.User.Guilds.Add(g);

                m.Guild = g;
                g.UpdateUserPermission(m);

                MemberAdd?.Invoke(g, m);
                break;
            }

            case Events.GUILD_MEMBER_REMOVE:
            {
                var g = Guilds[eventPayload["guild_id"].ToString()];
                var m = g.Members[eventPayload["user"]["id"].ToString()];

                g.Members.Remove(m.User.Id);
                m.User.Guilds.Remove(g);

                MemberRemove?.Invoke(g, m);
                break;
            }

            case Events.GUILD_MEMBER_UPDATE:
            {
                var g = Guilds[eventPayload["guild_id"].ToString()];
                var m = g.Members[eventPayload["user"]["id"].ToString()];

                JsonConvert.PopulateObject(payload, m);

                g.UpdateUserPermission(m);

                MemberUpdate?.Invoke(g, m);
                break;
            }

            case Events.GUILD_MEMBERS_CHUNK:
            {
                var g       = Guilds[eventPayload["guild_id"].ToString()];
                var members = eventPayload["members"].ToObject <List <GuildMember> >();

                foreach (var member in members)
                {
                    if (Users.ContainsKey(member.User.Id))
                    {
                        member.User = Users[member.User.Id];
                    }
                    else
                    {
                        Users.Add(member.User.Id, member.User);
                    }

                    g.Members.Remove(member.User.Id);
                    g.Members.Add(member.User.Id, member);
                }

                MemberChunkUpdate?.Invoke(g, members);
                break;
            }

            case Events.GUILD_ROLE_CREATE:
            {
                var g = Guilds[eventPayload["guild_id"].ToString()];
                var r = eventPayload["role"].ToObject <Guild.Role>();

                g.Roles.Add(r.Id, r);

                RoleCreate?.Invoke(g, r);
                break;
            }

            case Events.GUILD_ROLE_UPDATE:
            {
                var g = Guilds[eventPayload["guild_id"].ToString()];
                var r = g.Roles[eventPayload["role"]["id"].ToString()];

                JsonConvert.PopulateObject(eventPayload["role"].ToString(), r);

                RoleUpdate?.Invoke(g, r);
                break;
            }

            case Events.GUILD_ROLE_DELETE:
            {
                var g = Guilds[eventPayload["guild_id"].ToString()];
                var r = g.Roles[eventPayload["role_id"].ToString()];

                g.Roles.Remove(r.Id);

                RoleDelete?.Invoke(g, r);
                break;
            }

            case Events.MESSAGE_CREATE:
            {
                var message = eventPayload.ToObject <Message>();
                var c       = Channels[message.Channel_Id];

                message.Channel = c;

                if (string.IsNullOrEmpty(message.Webhook_Id))
                {
                    if (Users.ContainsKey(message.Author.Id))
                    {
                        message.Author = Users[message.Author.Id];
                    }
                }

                MessageCreate?.Invoke(c, message);
                break;
            }

            case Events.MESSAGE_UPDATE:
            {
                var message = eventPayload.ToObject <Message>();
                var c       = Channels[message.Channel_Id];

                MessageUpdate?.Invoke(c, message);
                break;
            }

            case Events.MESSAGE_DELETE:
            {
                var message = eventPayload.ToObject <Message>();
                var c       = Channels[message.Channel_Id];

                MessageDelete?.Invoke(c, message);
                break;
            }

            case Events.MESSAGE_DELETE_BULK:
            {
                var messages = eventPayload.ToObject <List <Message> >();
                var c        = Channels[eventPayload["channel_id"].ToString()];

                MessagesBulkDelete?.Invoke(c, messages);
                break;
            }

            case Events.PRESENCE_UPDATE:
            {
                var presense = eventPayload.ToObject <Guild.Presence>();
                var g        = Guilds[eventPayload["guild_id"].ToString()];

                if (g.Presences.ContainsKey(presense.User.Id))
                {
                    var p = g.Presences[presense.User.Id];

                    p.Game   = presense.Game;
                    p.Status = presense.Status;

                    presense = p;
                }
                else
                {
                    presense.User = Users[presense.User.Id];
                    g.Presences.Add(presense.User.Id, presense);
                }

                PresenceUpdate?.Invoke(g, presense);
                break;
            }
            }
        }
Ejemplo n.º 21
0
        public async Task <IActionResult> Post(RoleCreate command)
        {
            var result = await _mediator.Send(command);

            return(Ok(result));
        }