Пример #1
0
        public async Task <CreateRoleRes> CreateNewRole(CreateRoleReq newRole)
        {
            CreateRoleRes response = new CreateRoleRes();

            try
            {
                AppIdentityRole appIdentityRole = new AppIdentityRole
                {
                    Name         = newRole.RoleName,
                    IsActive     = newRole.IsActive,
                    RolePriority = newRole.RolePriority
                };
                var result = await _roleManager.CreateAsync(appIdentityRole);

                if (result.Succeeded)
                {
                    response.RoleId   = appIdentityRole.Id;
                    response.RoleName = appIdentityRole.Name;
                    response.Message  = "Vai trò mới đã được tạo";
                }
                else
                {
                    response.Message = "Đã có lỗi xảy ra xin liên hệ với Quản trị hệ thống";
                    return(response);
                }
                return(response);
            }
            catch (Exception ex)
            {
                response.Message = "Có lỗi đã xảy ra, xin mời liên lạc Quản trị hệ thống";
                return(response);
            }
        }
Пример #2
0
    public void SendMsg_CreateRole(string nickName, int profession, bool sex)
    {
        CreateRoleReq req = new CreateRoleReq()
        {
            nickName = nickName, profession = profession, sex = sex
        };

        Globals.Instance.SendMsg <CreateRoleReq>(Consts_CommandId.C2S_CreateRole, req);
    }
Пример #3
0
        /// <summary>
        /// Crear un rol
        /// </summary>
        /// <param name="pRoleName">Nombre del rol a crear</param>
        public static void CreateRole(string pRoleName)
        {
            CreateRoleReq req = new CreateRoleReq();

            req.BusinessData.Rol = new Rol(pRoleName);

            CreateRoleRes res = req.ExecuteService <CreateRoleReq, CreateRoleRes>(WrapperSecurityProvider, req);

            if (res.Error != null)
            {
                throw Fwk.Exceptions.ExceptionHelper.ProcessException(res.Error);
            }
        }
Пример #4
0
 public async Task <ActionResult> CreateRoleAsync([FromBody] CreateRoleReq createRoleReq)
 {
     try
     {
         //var result = await _roleLogic.CreateRoleAsync(category);
         //return Ok(new BaseResponse(result));
         return(null);
     }
     catch (Exception ex)
     {
         return(Ok(this.BaseResponseApiErrorResult(ex)));
     }
 }
Пример #5
0
        public void CreateRole(string name, uint playerID, uint hairCutIndex, uint hairColorIndex, uint faceIndex, int skinId)
        {
            isCreatingNewRole = true;

            CreateRoleReq createRoleReq = new CreateRoleReq();

            createRoleReq.account     = Logic.UI.Login.Model.LoginProxy.instance.cachedAccount;
            createRoleReq.roleName    = name;
            createRoleReq.playerId    = (int)playerID;
            createRoleReq.hairCutId   = (int)hairCutIndex;
            createRoleReq.hairColorId = (int)hairColorIndex;
            createRoleReq.faceId      = (int)faceIndex;
            createRoleReq.skinId      = skinId;
            createRoleReq.partnerId   = Logic.UI.Login.Model.LoginProxy.instance.cachedPlatformId;
            Logic.Protocol.ProtocolProxy.instance.SendProtocol(createRoleReq);

            /********** Legacy code, I'll remove them later **********/
            //			Game.Model.GameProxy.instance.PlayerInfo = new Logic.Player.Model.PlayerInfo(Game.Model.GameProxy.instance.PlayerInstanceID, playerID, hairCutIndex, hairColorIndex, faceIndex, name);
            //			UIMgr.instance.Open(UI.Main.View.MainView.PREFAB_PATH);
            /********** Legacy code, I'll remove them later **********/
        }
Пример #6
0
        //[TestMethod]
        void CreateRole_No_Service(string name)
        {
            String strErrorResut = String.Empty;

            CreateRoleService svc = new CreateRoleService();
            CreateRoleReq     req = new CreateRoleReq();

            req.BusinessData.Rol.RolName = rolName;
            req.SecurityProviderName     = SecurityProviderName;

            try
            {
                CreateRoleRes res = svc.Execute(req);
            }
            catch (Exception ex)
            {
                strErrorResut = Fwk.Exceptions.ExceptionHelper.GetAllMessageException(ex);
            }


            Assert.AreEqual <String>(strErrorResut, string.Empty, strErrorResut);
        }
Пример #7
0
        //[TestMethod]
         void CreateRole_No_Service(string name)
        {
            String strErrorResut = String.Empty;

            CreateRoleService svc = new CreateRoleService();
            CreateRoleReq req = new CreateRoleReq();
            
            req.BusinessData.Rol.RolName = rolName;
            req.SecurityProviderName = SecurityProviderName;

            try
            {
                CreateRoleRes res = svc.Execute(req);

            }
            catch (Exception ex)
            {
                strErrorResut = Fwk.Exceptions.ExceptionHelper.GetAllMessageException(ex);
            }


            Assert.AreEqual<String>(strErrorResut, string.Empty, strErrorResut);

        }
Пример #8
0
        /// <summary>
        /// Crear un rol
        /// </summary>
        /// <param name="pRoleName">Nombre del rol a crear</param>
        public static void CreateRole(string pRoleName)
        {
            CreateRoleReq req = new CreateRoleReq();
            req.BusinessData.Rol = new Rol(pRoleName);

            CreateRoleRes res = req.ExecuteService<CreateRoleReq, CreateRoleRes>(WrapperSecurityProvider,req);

            if (res.Error != null)
                throw Fwk.Exceptions.ExceptionHelper.ProcessException(res.Error);

        }
Пример #9
0
 public async Task <CreateRoleRes> CreateNewRole(CreateRoleReq request)
 {
     return(await _roleRepository.CreateNewRole(request));
 }
 public async Task <IActionResult> CreateNewRole(CreateRoleReq request)
 {
     return(Ok(await _roleService.CreateNewRole(request)));
 }