//### callback for Sample41
        public ActionResult sample41_callback()
        {
            // Get user info
            String infoFile = AppDomain.CurrentDomain.BaseDirectory + "user_info.txt";
            System.IO.StreamReader userInfoFile = new System.IO.StreamReader(infoFile);
            String clientId = userInfoFile.ReadLine();
            String privateKey = userInfoFile.ReadLine();
            userInfoFile.Close();

            // Check is data posted
            if (Request.HttpMethod == "POST")
            {
                //Get callback data from JSON
                System.IO.StreamReader reader = new System.IO.StreamReader(Request.InputStream);
                String jsonString = reader.ReadToEnd();
                var data = System.Web.Helpers.Json.Decode(jsonString);
                var serializedData = System.Web.Helpers.Json.Decode(data.SerializedData);
                String documentGuid = serializedData.DocumentGuid;
                documentGuid = documentGuid.Replace(" ", "");
                String collaboratorGuid = serializedData.UserGuid;
                collaboratorGuid = collaboratorGuid.Replace(" ", "");
                // Create service for Groupdocs account
                GroupdocsService service = new GroupdocsService("https://api.groupdocs.com/v2.0", clientId, privateKey);
                //Make request to api for get document info by job id
                if (documentGuid != "" && collaboratorGuid != "")
                {
                    //Get all collaborators for the document
                    Groupdocs.Api.Contract.Annotation.GetCollaboratorsResult getCollaborators = service.GetAnnotationCollaborators(documentGuid);
                    //Create ReviewerInfo array
                    Groupdocs.Api.Contract.ReviewerInfo[] reviewers = new Groupdocs.Api.Contract.ReviewerInfo[getCollaborators.Collaborators.Length];
                    for (int n = 0; n < getCollaborators.Collaborators.Length; n++)
                    {
                        //Set reviewer rights to view only
                        getCollaborators.Collaborators[n].AccessRights = Groupdocs.Common.AnnotationReviewerRights.CanView;
                        //Add riviewer to ReviewerInfo array
                        reviewers[n] = getCollaborators.Collaborators[n];

                    }
                    //Make request to API to update reviewer rights
                    Groupdocs.Api.Contract.Annotation.SetReviewerRightsResult setRights = service.SetReviewerRights(documentGuid, reviewers);
                    //path to settings file - temporary save clientId and apiKey like to property file
                    String callbackInfo = AppDomain.CurrentDomain.BaseDirectory + "callback_info.txt";
                    //open file in rewrite mode
                    FileStream fcreate = System.IO.File.Open(callbackInfo, FileMode.Create); // will create the file or overwrite it if it already exists
                    //String filePath = AppDomain.CurrentDomain.BaseDirectory + "user_info.txt";
                    System.IO.StreamWriter infoFileStreamWriter = new StreamWriter(fcreate);
                    //w = System.IO.File.CreateText(filePath);
                    infoFileStreamWriter.WriteLine("User rights was set to view only"); //save clientId
                    infoFileStreamWriter.Flush();
                    infoFileStreamWriter.Close();

                }
                return View("sample41_callback");
            }
            //If data not posted return to template for filling of necessary fields
            else
            {
                return View("sample41_callback");
            }
        }
        public ActionResult Sample22()
        {
            // Check is data posted
            if (Request.HttpMethod == "POST")
            {
                //### Set variables and get POST data
                System.Collections.Hashtable result = new System.Collections.Hashtable();
                String clientId = Request.Form["clientId"];
                String privateKey = Request.Form["privateKey"];
                String email = Request.Form["email"];
                String firstName = Request.Form["firstName"];
                String lastName = Request.Form["lastName"];
                String fileId = Request.Form["fileId"];
                String url = Request.Form["url"];
                var file = Request.Files["file"];
                String guid = "";
                String basePath = Request.Form["basePath"];
                // Set entered data to the results list
                result.Add("clientId", clientId);
                result.Add("privateKey", privateKey);
                result.Add("email", email);
                result.Add("firstName", firstName);
                result.Add("lastName", lastName);
                String message = null;
                // Check is all needed fields are entered
                if (String.IsNullOrEmpty(clientId) || String.IsNullOrEmpty(privateKey) || String.IsNullOrEmpty(email)
                    || String.IsNullOrEmpty(lastName) || String.IsNullOrEmpty(firstName))
                {
                    // If not all fields entered send error message
                    message = "Please enter all parameters";
                    result.Add("error", message);
                    return View("Sample22", null, result);
                }
                else
                {

                    if (basePath.Equals(""))
                    {
                        basePath = "https://api.groupdocs.com/v2.0";
                    }
                    result.Add("basePath", basePath);
                    // Create service for Groupdocs account
                    GroupdocsService service = new GroupdocsService(basePath, clientId, privateKey);

                    //if URL to web file was provided - upload the file from Web and get it's GUID
                    if (!url.Equals(""))
                    {

                        //Make request to upload file from entered Url
                        String uploadWeb = service.UploadUrl(url);
                        if (uploadWeb != null)
                        {
                            //If file uploaded return his GuId
                            guid = uploadWeb;

                        }
                        //If file wasn't uploaded return error
                        else
                        {
                            result.Add("error", "Something wrong with entered data");
                            return View("Sample22", null, result);
                        }

                    }
                    //if file was uploaded locally - upload the file and get it's GUID
                    if (!file.FileName.Equals(""))
                    {

                        //Upload local file
                        Groupdocs.Api.Contract.UploadRequestResult upload = service.UploadFile(file.FileName, String.Empty, file.InputStream);
                        if (upload.Guid != null)
                        {
                            //If file uploaded return his guid
                            guid = upload.Guid;

                        }
                        else
                        {
                            //If file wasn't uploaded return error
                            result.Add("error", "Something wrong with entered data");
                            return View("Sample22", null, result);
                        }

                    }
                    if (!fileId.Equals(""))
                    {
                        guid = fileId;

                    }
                    result.Add("fileId", guid);
                    //Create User info object
                    Groupdocs.Api.Contract.UserInfo user = new Groupdocs.Api.Contract.UserInfo();
                    //Create Role info object
                    Groupdocs.Api.Contract.RoleInfo roleInfo = new Groupdocs.Api.Contract.RoleInfo();
                    //Create array of roles.
                    Groupdocs.Api.Contract.RoleInfo[] roleList = new Groupdocs.Api.Contract.RoleInfo[1];
                    //Set user role Id. Can be: 1 -  SysAdmin, 2 - Admin, 3 - User, 4 - Guest
                    roleInfo.Id = 3;
                    //Set user role name. Can be: SysAdmin, Admin, User, Guest
                    roleInfo.Name = "User";
                    roleList[0] = roleInfo;
                    //Set nick name as entered first name
                    user.NickName = firstName;
                    //Set first name as entered first name
                    user.FirstName = firstName;
                    //Set last name as entered last name
                    user.LastName = lastName;
                    user.Roles = roleList;
                    //Set email as entered email
                    user.PrimaryEmail = email;
                    //Creating of new User user - object with new user info
                    Groupdocs.Api.Contract.UserIdentity newUser = service.UpdateAccountUser(user);
                    // If request return's null return error to the template
                    if (newUser.Guid != null)
                    {
                        //Create array with entered email for SetAnnotationCollaborators method
                        String[] emails = new String[1];
                        emails[0] = email;
                        //Make request to Ant api for set new user as annotation collaborator
                        Groupdocs.Api.Contract.Annotation.SetCollaboratorsResult addCollaborator = service.SetAnnotationCollaborators(guid, emails, "2.0");
                        if (addCollaborator.Collaborators != null)
                        {
                            //Set reviewers rights for new user.
                            Groupdocs.Api.Contract.Annotation.SetReviewerRightsResult setReviewer = service.SetReviewerRights(guid, addCollaborator.Collaborators);
                            String iframe = "";
                            if (basePath.Equals("https://api.groupdocs.com/v2.0"))
                            {
                                iframe = "https://apps.groupdocs.com//document-annotation2/embed/" + guid + "?&uid=" + newUser.Guid + "&download=true";
                            }
                            else if (basePath.Equals("https://dev-api-groupdocs.dynabic.com/v2.0"))
                            {
                                iframe = "https://dev-apps-groupdocs.dynabic.com//document-annotation2/embed/" + guid + "?&uid=" + newUser.Guid + "&download=true";
                            }
                            else if (basePath.Equals("https://stage-api-groupdocs.dynabic.com/v2.0"))
                            {
                                iframe = "https://stage-api-groupdocs.dynabic.com//document-annotation2/embed/" + guid + "?&uid=" + newUser.Guid + "&download=true";
                            }
                            else if (basePath.Equals("https://realtime-api-groupdocs.dynabic.com/v2.0"))
                            {
                                iframe = "https://realtime-apps-groupdocs.dynabic.com//document-annotation2/embed/" + guid + "?&uid=" + newUser.Guid + "&download=true";
                            }
                            //Sign iframe URL with private key
                            iframe = Groupdocs.Security.UrlSignature.Sign(iframe, privateKey);
                            //Return GuId of new User to the template
                            result.Add("url", iframe);
                            return View("Sample22", null, result);
                        }
                        //If Collaborators is empty return error
                        else
                        {
                            result.Add("error", "Collaborators is empty");
                            return View("Sample22", null, result);
                        }
                    }
                    //If upload file returns faile, return error to the template
                    else
                    {
                        result.Add("error", "Upload is failed");
                        return View("Sample22", null, result);
                    }

                }

            }
            // If data not posted return to template for filling of necessary fields
            else
            {
                return View("Sample22");
            }
        }