Ejemplo n.º 1
0
        public ActionResult Create(string clickwrapId, string clickwrapName)
        {
            // Obtain your OAuth token
            var accessToken = RequestItemsService.User.AccessToken;
            var basePath    = $"{RequestItemsService.Session.BasePath}/clickapi"; // Base API path
            var accountId   = RequestItemsService.Session.AccountId;

            try
            {
                // Call the Click API to create the clickwrap version
                var clickWrap = CreateNewClickwrapVersion.Create(clickwrapId, basePath, accessToken, accountId, clickwrapName);

                // Show results
                ViewBag.h1          = "Create a new clickwrap version";
                ViewBag.message     = $"Version {clickWrap.VersionNumber} of clickwrap {clickWrap.ClickwrapName} has been created.";
                ViewBag.Locals.Json = JsonConvert.SerializeObject(clickWrap, 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 ActionResult Create()
        {
            // Obtain your OAuth token
            var accessToken = RequestItemsService.User.AccessToken;
            var basePath    = $"{RequestItemsService.Session.BasePath}/clickapi"; // Base API path
            var accountId   = RequestItemsService.Session.AccountId;

            try
            {
                if (string.IsNullOrEmpty(RequestItemsService.ClickwrapId))
                {
                    ViewBag.errorCode    = 400;
                    ViewBag.errorMessage = "Cannot find any clickwrap. Please first create a clickwrap using the first example.";

                    return(View("Error"));
                }

                var clickwrapId = RequestItemsService.ClickwrapId;

                // Call the Click API to create the clickwrap version
                var clickWrap = CreateNewClickwrapVersion.Create(clickwrapId, basePath, accessToken, accountId);

                // Show results
                ViewBag.h1          = "A new clickwrap version was successfully created";
                ViewBag.message     = $"The new clickwrap version was created! Clickwrap ID: {clickWrap.ClickwrapId}, Name: {clickWrap.ClickwrapName}.";
                ViewBag.Locals.Json = JsonConvert.SerializeObject(clickWrap, Formatting.Indented);

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

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