Example #1
0
        public static async Task <PortalViewModel> Get(ISEConnection connection, Guid id)
        {
            var response = await connection.RestGet("config/portal/" + id.ToString());

            if (response.IsSuccessStatusCode)
            {
                var json = await response.Content.ReadAsStringAsync();

                var typeDef = new
                {
                    ERSPortal = new PortalViewModel()
                };

                var getResult = JsonConvert.DeserializeAnonymousType(json, typeDef);

                return((
                           getResult != null &&
                           getResult.ERSPortal != null) ?
                       getResult.ERSPortal :
                       null);
            }
            else
            {
                //Console.WriteLine("{0} ({1})", (int)response.StatusCode, response.ReasonPhrase);
                System.Diagnostics.Debug.WriteLine("{0} ({1})", (int)response.StatusCode, response.ReasonPhrase);
            }

            return(null);
        }
Example #2
0
        public static async Task <List <GuestLocationViewModel> > Get(ISEConnection connection)
        {
            var response = await connection.RestGet("config/guestlocation");

            if (response.IsSuccessStatusCode)
            {
                var json = await response.Content.ReadAsStringAsync();

                var typeDef = new
                {
                    SearchResult = new
                    {
                        total     = (int)0,
                        resources = new List <GuestLocationViewModel>()
                    }
                };

                var portals = JsonConvert.DeserializeAnonymousType(json, typeDef);

                return((
                           portals != null &&
                           portals.SearchResult != null &&
                           portals.SearchResult.resources != null) ?
                       portals.SearchResult.resources :
                       null);
            }
            else
            {
                //Console.WriteLine("{0} ({1})", (int)response.StatusCode, response.ReasonPhrase);
                System.Diagnostics.Debug.WriteLine("{0} ({1})", (int)response.StatusCode, response.ReasonPhrase);
            }

            return(null);
        }
Example #3
0
        public static async Task <GuestUserViewModel> Get(ISEConnection connection, string name)
        {
            HttpResponseMessage response;

            try
            {
                response = await connection.RestGet("config/guestuser/name/" + name);
            } catch {
                System.Diagnostics.Trace.WriteLine("Failed to get result from config/guestuser/name/" + name, "ISEError");
                return(null);
            }

            if (response.IsSuccessStatusCode)
            {
                var json = await response.Content.ReadAsStringAsync();

                var typeDef   = new { GuestUser = new GuestUserViewModel() };
                var guestUser = JsonConvert.DeserializeAnonymousType(json, typeDef);

                return((guestUser != null && guestUser.GuestUser != null) ?
                       guestUser.GuestUser :
                       null);
            }
            else
            {
                //Console.WriteLine("{0} ({1})", (int)response.StatusCode, response.ReasonPhrase);
                System.Diagnostics.Debug.WriteLine("{0} ({1})", (int)response.StatusCode, response.ReasonPhrase);
            }

            return(null);
        }