Пример #1
0
        public ActionResult ExportData(RoomsListModel model)
        {
            // Obtain your OAuth token
            string accessToken = RequestItemsService.User.AccessToken;                      // Represents your {ACCESS_TOKEN}
            var    basePath    = $"{RequestItemsService.Session.RoomsApiBasePath}/restapi"; // Base API path
            string accountId   = RequestItemsService.Session.AccountId;                     // Represents your {ACCOUNT_ID}

            try
            {
                // Call the Rooms API to get room field data
                var fieldData = ExportDataFromRoom.Export(basePath, accessToken, accountId, model.RoomId);

                // Show results
                ViewBag.h1          = "The room data was successfully exported";
                ViewBag.message     = $"Results from the Rooms::GetRoomFieldData method RoomId: {model.RoomId} :";
                ViewBag.Locals.Json = JsonConvert.SerializeObject(fieldData, Formatting.Indented);

                return(View("example_done"));
            }
            catch (ApiException apiException)
            {
                ViewBag.errorCode    = apiException.ErrorCode;
                ViewBag.errorMessage = apiException.Message;

                return(View("Error"));
            }
        }
Пример #2
0
        public override IActionResult Get()
        {
            base.Get();

            // Obtain your OAuth token
            string accessToken = RequestItemsService.User.AccessToken;                      // Represents your {ACCESS_TOKEN}
            var    basePath    = $"{RequestItemsService.Session.RoomsApiBasePath}/restapi"; // Base API path
            string accountId   = RequestItemsService.Session.AccountId;                     // Represents your {ACCOUNT_ID}

            try
            {
                // Get Rooms
                var rooms = ExportDataFromRoom.GetRooms(basePath, accessToken, accountId);

                RoomsListModel = new RoomsListModel {
                    Rooms = rooms.Rooms.ToList()
                };

                return(View("Eg03", this));
            }
            catch (ApiException apiException)
            {
                ViewBag.errorCode    = apiException.ErrorCode;
                ViewBag.errorMessage = apiException.Message;

                return(View("Error"));
            }
        }