Ejemplo n.º 1
0
        public ActionResult ExportData(RoomFormModel roomFormModel)
        {
            // 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 add form to a room
                var roomDocument = AddingFormToRoom.AddForm(basePath,
                                                            accessToken,
                                                            accountId,
                                                            roomFormModel.RoomId,
                                                            roomFormModel.FormId);

                ViewBag.h1          = "The form was successfully added to a room";
                ViewBag.message     = $"Results from the Rooms: AddFormToRoom method. RoomId: {roomFormModel.RoomId}, FormId: {roomFormModel.FormId} :";
                ViewBag.Locals.Json = JsonConvert.SerializeObject(roomDocument, Formatting.Indented);

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

                return(View("Error"));
            }
        }
Ejemplo n.º 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 and forms
                (FormSummaryList forms, RoomSummaryList rooms) = AddingFormToRoom.GetFormsAndRooms(basePath, accessToken, accountId);

                RoomFormModel = new RoomFormModel {
                    Forms = forms.Forms, Rooms = rooms.Rooms
                };

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

                ApiError error = JsonConvert.DeserializeObject <ApiError>(apiException.ErrorContent);
                if (error.ErrorCode.Equals("FORMS_INTEGRATION_NOT_ENABLED", StringComparison.InvariantCultureIgnoreCase))
                {
                    return(View("ExampleNotAvailable"));
                }
                return(View("Error"));
            }
        }
        public override IActionResult Get()
        {
            base.Get();
            // Step 1. Obtain your OAuth token
            string accessToken = RequestItemsService.User.AccessToken;                      // Represents your {ACCESS_TOKEN}
            var    basePath    = $"{RequestItemsService.Session.RoomsApiBasePath}/restapi"; // Base API path

            // Step 2: Construct your API headers
            var apiClient = new ApiClient(basePath);

            apiClient.Configuration.DefaultHeader.Add("Authorization", "Bearer " + accessToken);
            var roomsApi         = new RoomsApi(apiClient);
            var formLibrariesApi = new FormLibrariesApi(apiClient);

            string accountId = RequestItemsService.Session.AccountId; // Represents your {ACCOUNT_ID}

            try
            {
                //Step 3: Get Forms Libraries
                FormLibrarySummaryList formLibraries = formLibrariesApi.GetFormLibraries(accountId);

                //Step 4: Get Forms
                FormSummaryList forms = new FormSummaryList(new List <FormSummary>());
                if (formLibraries.FormsLibrarySummaries.Any())
                {
                    forms = formLibrariesApi.GetFormLibraryForms(
                        accountId,
                        formLibraries.FormsLibrarySummaries.First().FormsLibraryId);
                }

                //Step 5: Get Rooms
                RoomSummaryList rooms = roomsApi.GetRooms(accountId);

                RoomFormModel = new RoomFormModel {
                    Forms = forms.Forms, Rooms = rooms.Rooms
                };

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

                ApiError error = JsonConvert.DeserializeObject <ApiError>(apiException.ErrorContent);
                if (error.ErrorCode.Equals("FORMS_INTEGRATION_NOT_ENABLED", StringComparison.InvariantCultureIgnoreCase))
                {
                    return(View("ExampleNotAvailable"));
                }
                return(View("Error"));
            }
        }
        public ActionResult ExportData(RoomFormModel roomFormModel)
        {
            // Step 1. Obtain your OAuth token
            string accessToken = RequestItemsService.User.AccessToken;                      // Represents your {ACCESS_TOKEN}
            var    basePath    = $"{RequestItemsService.Session.RoomsApiBasePath}/restapi"; // Base API path

            // Step 2: Construct your API headers
            var apiClient = new ApiClient(basePath);

            apiClient.Configuration.DefaultHeader.Add("Authorization", "Bearer " + accessToken);
            var roomsApi = new RoomsApi(apiClient);

            string accountId = RequestItemsService.Session.AccountId; // Represents your {ACCOUNT_ID}

            try
            {
                // Step 3: Call the Rooms API to add form to a room
                RoomDocument roomDocument = roomsApi.AddFormToRoom(
                    accountId,
                    roomFormModel.RoomId,
                    new FormForAdd(roomFormModel.FormId));

                ViewBag.h1          = "The form was successfully added to a room";
                ViewBag.message     = $"Results from the Rooms: AddFormToRoom method. RoomId: {roomFormModel.RoomId}, FormId: {roomFormModel.FormId} :";
                ViewBag.Locals.Json = JsonConvert.SerializeObject(roomDocument, Formatting.Indented);

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

                return(View("Error"));
            }
        }
 protected override void InitializeInternal()
 {
     RoomFormModel = new RoomFormModel();
 }