示例#1
0
        public SecurityModels.GetPermissionsResponse GetPermissions(SecurityModels.GetListRequest getPermissionsRequest)
        {
            SecurityModels.GetPermissionsResponse getPermissionsResponse = new SecurityModels.GetPermissionsResponse();
            List <SecurityModels.Permission>      Permissions            = new List <SecurityModels.Permission>();

            using (SqlConnection con = new SqlConnection(securityConnectionString))
            {
                using (SqlCommand cmd = new SqlCommand("GetPermissions", con))
                {
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.Add("@searchParm", SqlDbType.VarChar, 30).Value = getPermissionsRequest.searchParm;
                    con.Open();
                    SqlDataReader reader       = cmd.ExecuteReader();
                    int           recordNumber = 1;

                    while (reader.Read())
                    {
                        if (recordNumber == 1)
                        {
                            getPermissionsResponse.recordCount = Convert.ToInt32(reader["recordCount"].ToString());
                        }

                        Permissions.Add(new SecurityModels.Permission
                        {
                            id          = Convert.ToInt32(reader["ID"].ToString()),
                            name        = reader["Name"].ToString(),
                            displayName = reader["displayName"].ToString(),
                            active      = Convert.ToBoolean(reader["Active"].ToString())
                        });
                    }
                    getPermissionsResponse.permissions = Permissions;
                }
                con.Close();
            }
            return(getPermissionsResponse);
        }
示例#2
0
 public IActionResult GetPermissions([FromQuery] SecurityModels.GetListRequest getPermissionsRequest)
 {
     SecurityModels.GetPermissionsResponse getPermissionsResponse = securityInventoryRepo.GetPermissions(getPermissionsRequest);
     return(StatusCode(StatusCodes.Status200OK, getPermissionsResponse));
 }