Exemple #1
0
        public SecurityModels.GetRolesResponse GetRoles(SecurityModels.GetListRequest getRolesRequest)
        {
            SecurityModels.GetRolesResponse getRolesResponse = new SecurityModels.GetRolesResponse();
            List <SecurityModels.Role>      Roles            = new List <SecurityModels.Role>();

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

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

                        recordNumber++;

                        Roles.Add(new SecurityModels.Role
                        {
                            id          = Convert.ToInt32(reader["ID"].ToString()),
                            name        = reader["Name"].ToString(),
                            displayName = reader["displayName"].ToString(),
                            active      = Convert.ToBoolean(reader["Active"].ToString())
                        });
                    }
                    getRolesResponse.roles = Roles;
                }
                con.Close();
            }
            return(getRolesResponse);
        }
Exemple #2
0
 public IActionResult GetRoles([FromQuery] SecurityModels.GetListRequest getRolesRequest)
 {
     SecurityModels.GetRolesResponse getRolesResponse = securityInventoryRepo.GetRoles(getRolesRequest);
     return(StatusCode(StatusCodes.Status200OK, getRolesResponse));
 }