예제 #1
0
        public int AddRole(VRole vRole)
        {
            var role = new Role();

            role.Name       = vRole.Name;
            role.Updatetime = DateTime.UtcNow;
            role.Code       = Guid.NewGuid().ToString();
            var result = _role.Add(role);

            role = GetRoleByCode(role.Code).SingleOrDefault();
            if (result > 0)
            {
                if (vRole.MenuId == null || !vRole.MenuId.Any())
                {
                    return(result);
                }

                var menuRole = vRole.MenuId.Select(t =>
                {
                    var value        = new MenuRole();
                    value.Menu       = t;
                    value.Role       = role.Id;
                    value.Updatetime = DateTime.UtcNow;
                    return(value);
                });
                return(_menuRole.Add(menuRole));
            }
            return(-1);
        }
예제 #2
0
        public void ProcessMessage(IHandlerContext <AddRoleCommand> context)
        {
            var message = context.Message;

            if (string.IsNullOrEmpty(message.Name))
            {
                return;
            }

            using (_databaseContextFactory.Create())
            {
                var key = Role.Key(message.Name);

                if (_keyStore.Contains(key))
                {
                    return;
                }

                var id = Guid.NewGuid();

                _keyStore.Add(id, key);

                var role   = new Role(id);
                var stream = _eventStore.CreateEventStream(id);

                stream.AddEvent(role.Add(message.Name));

                _eventStore.Save(stream);
            }
        }
예제 #3
0
 public UserDtoZ(string username, string email, HashSet <Role> roles) : this()
 {
     Username = username;
     Email    = email;
     foreach (var role in roles)
     {
         Role.Add(role);
     }
 }
예제 #4
0
        public override object Perform_Task()
        {
            foreach (var parameterName in _knownParameterNames)
            {
                int paramValue;
                int.TryParse(Details.Value_Of(parameterName), out paramValue);

                Role.Add(paramValue);
            }

            return(true);
        }
예제 #5
0
 protected void btnConfrim_Click(object sender, EventArgs e)
 {
     if (Page.IsValid)
     {
         List <TablePrimary> t           = new List <TablePrimary>();
         TablePrimary        userPrimary = new TablePrimary();
         userPrimary.PrimaryName  = "RoleName";
         userPrimary.PrimaryValue = GetRoleInfo().RoleName;
         t.Add(userPrimary);
         if (Request.QueryString["Type"] != null && Request.QueryString["Type"].ToString() == "0")//新增状态
         {
             if (Common.IsExsit("Role", t))
             {
                 ScriptManager.RegisterStartupScript(UpdatePanel1, this.GetType(), "Fail", "alert('角色已经存在,请确认!');", true);
             }
             else
             {
                 bool iResult = Role.Add(GetRoleInfo().RoleName, GetRoleInfo().Remark);
                 if (iResult)
                 {
                     ScriptManager.RegisterStartupScript(UpdatePanel1, this.GetType(),
                                                         "Sucess", "alert('操作成功!');location.replace('RoleList.aspx?Refresh=1');", true);
                 }
                 else
                 {
                     ScriptManager.RegisterStartupScript(UpdatePanel1, this.GetType(), "Fail", "alert('操作失败!');", true);
                 }
             }
         }
         else
         {
             if (Common.IsExsit("Role", t, GetRoleInfo().RoleID))
             {
                 ScriptManager.RegisterStartupScript(UpdatePanel1, this.GetType(), "Fail", "alert('角色已经存在,请确认!');", true);
             }
             else
             {
                 bool bResult = Role.Update(GetRoleInfo().RoleName, GetRoleInfo().Remark, GetRoleInfo().RoleID);
                 if (bResult)
                 {
                     ScriptManager.RegisterStartupScript(UpdatePanel1, this.GetType(),
                                                         "Sucess", "alert('操作成功!');location.replace('RoleList.aspx?Refresh=1');", true);
                 }
                 else
                 {
                     ScriptManager.RegisterStartupScript(UpdatePanel1, this.GetType(), "Fail", "alert('操作失败!');", true);
                 }
             }
         }
     }
 }
        private void Insert_Role()
        {
            Role repository = new Role();

            if (repository.Add(get_Data_From_Form()))
            {
                this.ShowSuccessfulNotification("Role created successfully");
                clear_form();
                Load_Data_Grid();
            }
            else
            {
                this.ShowErrorNotification("Error occured");
            }
        }
예제 #7
0
 public int?AddRole(RoleEntity objRole)
 {
     if (WebOperationContext.Current.IncomingRequest.Method == "OPTIONS")
     {
         return(null);
     }
     else
     {
         try
         {
             return(Role.Add(objRole));
         }
         catch (Exception ex)
         {
             throw new WebFaultException <string>(ex.Message, HttpStatusCode.ExpectationFailed);
         }
     }
 }
예제 #8
0
        public Role GetRole(int id, bool withPermission)
        {
            using (IDbConnection connection = OpenConnection())
            {
                Role role = connection.Query <Role>(
                    @"SELECT RoleId, Name FROM rbac_role WHERE RoleId = @RoleId;",
                    new { RoleId = id }).SingleOrDefault();
                if (withPermission)
                {
                    var permissions = connection.Query <Permission>(
                        @"SELECT p.PermissionId, p.Name 
FROM rbac_permission p 
JOIN rbac_role_permission rp ON p.PermissionId = rp.PermissionId 
WHERE rp.RoleId = @RoleId;",
                        new { RoleId = id });
                    role.Add(permissions);
                }
                return(role);
            }
        }
예제 #9
0
        public void Execute(AddRoleCommand command)
        {
            Role role = new Role(IdWorker.NextId());
            var  rlt  = role.Add(command.Name);

            if (!rlt.success)
            {
                command.Result.Status = false;
                command.Result.Msg    = rlt.msg;
                return;
            }

            var rltR = _roleRepository.Add(role);

            if (!rltR.success)
            {
                command.Result.Status = false;
                command.Result.Msg    = rltR.msg;
                return;
            }
            command.Id            = role.ID;
            command.Result.Status = true;
        }
예제 #10
0
 public override object Perform_Task()
 {
     return(Role.Add(1));
 }
예제 #11
0
 public int AddRole(RoleEntity objRole)
 {
     return(Role.Add(objRole));
 }
예제 #12
0
 public override void Body()
 {
     role.Add("战士的身体建造完成");
 }