private async Task CreateContactDocumentLocation(IDynamicsClient _dynamicsClient, FileManagerClient _fileManagerClient, MicrosoftDynamicsCRMcontact contact)
        {
            string folderName;
            string logFolderName = "";

            try
            {
                folderName    = contact.GetDocumentFolderName();
                logFolderName = WordSanitizer.Sanitize(folderName);

                var createFolderRequest = new CreateFolderRequest()
                {
                    EntityName = "contact",
                    FolderName = folderName
                };

                var createFolderResult = _fileManagerClient.CreateFolder(createFolderRequest);

                if (createFolderResult.ResultStatus == ResultStatus.Fail)
                {
                    _logger.Error($"Error creating folder for contact {logFolderName}. Error is {createFolderResult.ErrorDetail}");
                }
            }
            catch (Exception e)
            {
                _logger.Error(e, $"Error creating folder for contact {logFolderName}");
            }
        }
Example #2
0
        /// <summary>
        /// Create the folder
        /// </summary>
        /// <param name="request">Request. <see cref="CreateFolderRequest" /></param>
        public void CreateFolder(CreateFolderRequest request)
        {
            // verify the required parameter 'path' is set
            if (request.path == null)
            {
                throw new ApiException(400, "Missing required parameter 'path' when calling CreateFolder");
            }

            // create path and map variables
            var resourcePath = this.configuration.GetServerUrl() + "/editor/storage/folder/{path}";

            resourcePath = Regex
                           .Replace(resourcePath, "\\*", string.Empty)
                           .Replace("&amp;", "&")
                           .Replace("/?", "?");
            resourcePath = UrlHelper.AddPathParameter(resourcePath, "path", request.path);
            resourcePath = UrlHelper.AddQueryParameterToUrl(resourcePath, "storageName", request.storageName);

            this.apiInvoker.InvokeApi(
                resourcePath,
                "PUT",
                null,
                null,
                null);
        }
        public async Task <IActionResult> CreateFolder([FromBody] CreateFolderRequest request)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(BadRequest(ModelState));
                }

                var callerEmail = User.FindFirst(ClaimTypes.NameIdentifier).Value;
                var response    = await _folderService.AddFolderAsync(callerEmail, request);

                if (!_folderService.State.IsValid)
                {
                    return(ServiceResponseDispatcher.ExecuteServiceResponse(this, _folderService.State.TypeOfError,
                                                                            _folderService.State.ErrorMessage));
                }

                return(CreatedAtRoute("GetFolder", new { uniqFolderId = response.UniqueFolderId }, response));
            }
            catch (Exception ex)
            {
                return(StatusCode(500, ex.Message));
            }
        }
Example #4
0
        protected override void ProcessRecord()
        {
            base.ProcessRecord();
            CreateFolderRequest request;

            try
            {
                request = new CreateFolderRequest
                {
                    CatalogId           = CatalogId,
                    DataAssetKey        = DataAssetKey,
                    CreateFolderDetails = CreateFolderDetails,
                    OpcRequestId        = OpcRequestId,
                    OpcRetryToken       = OpcRetryToken
                };

                response = client.CreateFolder(request).GetAwaiter().GetResult();
                WriteOutput(response, response.Folder);
                FinishProcessing(response);
            }
            catch (Exception ex)
            {
                TerminatingErrorDuringExecution(ex);
            }
        }
Example #5
0
        private static void CreateFolder()
        {
            CreateFolderRequest request = new CreateFolderRequest(1, "TestFolder", "It's a test folder creation.");
            Node createdFolderNode      = dc.Nodes.CreateFolder(request);

            Console.WriteLine("Created folder id: " + createdFolderNode.Id + "; Name: " + createdFolderNode.Name);
        }
Example #6
0
        public async Task <CreateFolderResponse> CreateFolderAsync(CreateFolderRequest model)
        {
            try
            {
                string        json          = JsonConvert.SerializeObject(model);
                StringContent stringContent = new StringContent(json, Encoding.Default, "application/json");

                var result = await client.PostAsync(API_VERSION + "/createFolder", stringContent);

                if (result.StatusCode == HttpStatusCode.Unauthorized)
                {
                    return(new CreateFolderResponse
                    {
                        Success = false,
                        Errors = new List <string> {
                            "Unauthorized. Please check your API Key and API Secret."
                        }
                    });
                }
                var jsonResponse = await result.Content.ReadAsStringAsync();

                var response = JsonConvert.DeserializeObject <CreateFolderResponse>(jsonResponse);

                return(response);
            }
            catch (Exception e)
            {
                var ex = new Image4ioException("There is an error while creating folder", e);
                throw ex;
            }
        }
        public void TestCopyMoveFile()
        {
            var testFile = TestFiles.Docx;

            // Create temp folder
            var cRequest = new CreateFolderRequest("temp");
            FolderApi.CreateFolder(cRequest);

            // Copy file
            var destPath = $"temp/{testFile.FileName}";
            var request = new CopyFileRequest(testFile.FullName, destPath);
            FileApi.CopyFile(request);

            // Check copied file
            var eRequest = new ObjectExistsRequest(destPath);
            var eResponse = StorageApi.ObjectExists(eRequest);
            Assert.IsTrue(eResponse.Exists);

            // Move file
            var newDestPath = $"temp/{testFile.FileName.Replace(".", "_1.")}";
            var mRequest = new MoveFileRequest(destPath, newDestPath);
            FileApi.MoveFile(mRequest);

            // Check moved file
            eRequest = new ObjectExistsRequest(newDestPath);
            eResponse = StorageApi.ObjectExists(eRequest);
            Assert.IsTrue(eResponse.Exists);

            // Delete temp folder
            var delRequest = new DeleteFolderRequest("temp", null, true);
            FolderApi.DeleteFolder(delRequest);
        }
        public override CommandResult Execute()
        {
            CommandResult result = new CommandResult(Command, Args);

            if (Args.Length == 0)
            {
                return(CommandResult.CreateError(Command, Args, "You must specify a folder name"));
            }

            if (Regex.Match(Args[0], "[\\\\/\\.]+").Success)
            {
                return(CommandResult.CreateError(Command, Args, "Folder name cannot contain characters '\\' '/' '.'"));
            }


            CreateFolderRequest cfr = new CreateFolderRequest(Args[0], Shell.CurrentFolder,
                                                              delegate(IRequest req)
            {
                CreateFolderProcessor cfp = req.GetProcessorAsType <CreateFolderProcessor>();
                if (cfp.FolderCreated)
                {
                    IFolder parentFolder = Shell.CurrentFolder;
                    Shell.Client.MailboxManager.AddFolder(Args[0], parentFolder);
                }
            });

            Shell.Client.RequestManager.SubmitAndWait(cfr, false);



            return(result);
        }
Example #9
0
        public async Task <object> CreateFolder(CreateFolderRequest req)
        {
            var date     = DateTime.Now;
            var pathName = string.Empty;

            if (!string.IsNullOrEmpty(req.Cate))
            {
                var cateModel = (await FilesService.GetInfo(req.Cate)).First;
                if (cateModel == null)
                {
                    throw new ArgumentException();
                }
                else
                {
                    pathName = cateModel.PathName;
                }
            }
            var keyName = $"{date.ToString("yyyyMMdd")}_{Guid.NewGuid().ToString()}";

            var fileModel = new FileModel()
            {
                KeyName  = keyName,
                FileName = req.Name,
                Date     = DateTime.Now,
                IsPublic = req.IsPublic,
                Owner    = User.Identity.Name,
                Cate     = string.IsNullOrEmpty(req.Cate) ? null : req.Cate,
                PathName = string.IsNullOrEmpty(pathName) ? req.Name : $"{pathName}/{req.Name}",
                IsFolder = true
            };

            return(new MessageDataResult(await FilesService.SaveItem(fileModel), "Create Folder"));
        }
        public IActionResult CreateFolder(CreateFolderRequest request)
        {
            if (_folderRepo.Any(f => f.FolderName == request.NewFolderName && f.ParentFolderId == request.ParentFolderId))
            {
                return(BadRequest("В текущей папке уже существует папка с таким именем"));
            }

            if (!_folderRepo.Any(f => request.ParentFolderId == f.Id) && request.ParentFolderId != Guid.Empty)
            {
                return(BadRequest("Папки с указанным id не существует!"));
            }

            if (request.ParentFolderId != Guid.Empty && !UserHasRole(request.ParentFolderId, AccessLevel.Create))
            {
                return(BadRequest("Не достаточно уровня прав доступа!"));
            }

            var newFolder = new Folder
            {
                ParentFolderId = request.ParentFolderId,
                FolderName     = request.NewFolderName
            };

            DiskHelper.CreateFolder(_folderService.GetFullPath(request.ParentFolderId), request.NewFolderName);
            _db.Set <UsersFolders>().Add(new UsersFolders
            {
                AccessLevel = AccessLevel.Owner,
                User        = UserContext,
                Folder      = newFolder
            });
            _db.Set <Folder>().Add(newFolder);
            _db.SaveChanges();

            return(CreatedAtAction(nameof(GetFolder), routeValues: new { folderId = newFolder.Id }, newFolder.Id));
        }
        private async Task CreateSharePointWorkerDocumentLocation(FileManagerClient _fileManagerClient, MicrosoftDynamicsCRMadoxioWorker worker)
        {
            string folderName    = "";
            string logFolderName = "";

            try
            {
                folderName    = worker.GetDocumentFolderName();
                logFolderName = WordSanitizer.Sanitize(folderName);

                var createFolderRequest = new CreateFolderRequest
                {
                    EntityName = "worker",
                    FolderName = folderName
                };

                var createFolderResult = _fileManagerClient.CreateFolder(createFolderRequest);

                if (createFolderResult.ResultStatus == ResultStatus.Fail)
                {
                    _logger.Error($"Error creating folder for contact {logFolderName}. Error is {createFolderResult.ErrorDetail}");
                }
            }
            catch (Exception e)
            {
                _logger.Error(e, $"Error creating folder for contact {logFolderName}");
            }
        }
Example #12
0
        public void TestCreateFolder()
        {
            var request = new CreateFolderRequest(
                path: remoteDataFolder + "/TestCreateFolder"
                );

            this.WordsApi.CreateFolder(request);
        }
        public override Task <CreateFolderReply> CreateFolder(CreateFolderRequest request, ServerCallContext context)
        {
            var result = new CreateFolderReply();

            var logFolder = WordSanitizer.Sanitize(request.FolderName);

            var listTitle = GetDocumentListTitle(request.EntityName);

            var _sharePointFileManager = new SharePointFileManager(_configuration);

            CreateDocumentLibraryIfMissing(listTitle, GetDocumentTemplateUrlPart(request.EntityName));

            var folderExists = false;

            try
            {
                var folder = _sharePointFileManager.GetFolder(listTitle, request.FolderName).GetAwaiter().GetResult();
                if (folder != null)
                {
                    folderExists = true;
                }
            }
            catch (SharePointRestException ex)
            {
                Log.Error(ex,
                          $"SharePointRestException creating sharepoint folder (status code: {ex.Response.StatusCode})");
                folderExists = false;
            }
            catch (Exception e)
            {
                Log.Error(e, "Generic Exception creating sharepoint folder");
                folderExists = false;
            }

            if (folderExists)
            {
                result.ResultStatus = ResultStatus.Success;
            }
            else
            {
                try
                {
                    _sharePointFileManager.CreateFolder(GetDocumentListTitle(request.EntityName), request.FolderName)
                    .GetAwaiter().GetResult();
                    var folder = _sharePointFileManager.GetFolder(listTitle, request.FolderName).GetAwaiter()
                                 .GetResult();
                    if (folder != null)
                    {
                        result.ResultStatus = ResultStatus.Success;
                    }
                }
                catch (SharePointRestException ex)
                {
                    result.ResultStatus = ResultStatus.Fail;
                    result.ErrorDetail  = $"ERROR in creating folder {logFolder}";
                    Log.Error(ex, result.ErrorDetail);
                }
            }
Example #14
0
 public IHttpActionResult CreateFolder([FromBody] CreateFolderRequest folder)
 {
     folder.ValidateContent();
     return(Ok(new CreateFolderResponse()
     {
         Data = _folderManipulation.Add(folder),
         Success = Common.Enumerations.ResponseStatus.Succeeded
     }));
 }
Example #15
0
        public async Task <FolderDto> AddFolderAsync(string userEmail, CreateFolderRequest folder)
        {
            try
            {
                var owner = await _unitOfWork.UserRepository.GetUserAsync(userEmail);


                Node parentDirectoryOfFile;
                if (folder.ParentFolderId == null)
                {
                    parentDirectoryOfFile = await _unitOfWork.NodeRepository.GetRootFolderForUserAsync(owner.Id);
                }
                else
                {
                    parentDirectoryOfFile = await _unitOfWork.NodeRepository.GetFolderByIdForUserAsync(folder.ParentFolderId.Value, owner.Id);
                }

                // Validate current Node (folder that file uploading to)
                if (!ValidateAccessToFolder(State, parentDirectoryOfFile, owner))
                {
                    return(null);
                }

                var existedFolder = await _unitOfWork.NodeRepository.GetFolderByNameForUserAsync(folder.Name, owner.Id);

                if (existedFolder != null)
                {
                    State.ErrorMessage = "Folder with this name already exist!";
                    State.TypeOfError  = TypeOfServiceError.BadRequest;
                    return(null);
                }

                var newFolder = new Node()
                {
                    IsDirectory = true,
                    Created     = DateTime.Now,
                    Folder      = parentDirectoryOfFile,
                    Owner       = owner,
                    Name        = folder.Name
                };

                _unitOfWork.NodeRepository.AddNode(newFolder);
                parentDirectoryOfFile.Siblings.Add(newFolder);

                await _unitOfWork.CommitAsync();

                //return Mapper.Map<Node, FolderDto>(folder);
                return(Mapper.Map <Node, FolderDto>(newFolder));
            }
            catch (Exception ex)
            {
                State.ErrorMessage = ex.Message;
                State.TypeOfError  = TypeOfServiceError.ServiceError;
                return(null);
            }
        }
Example #16
0
        public CreateFolderRequest createFolderRequest()
        {
            CreateFolderRequest folderRequest = new CreateFolderRequest()
            {
                Name           = "Root",
                ParentFolderId = 1
            };

            return(folderRequest);
        }
        internal static ApiCreateFolderRequest ToApiCreateFolderRequest(CreateFolderRequest createFolderRequest)
        {
            ApiCreateFolderRequest apiCreateFolderRequest = new ApiCreateFolderRequest {
                ParentId = createFolderRequest.ParentId,
                Name     = createFolderRequest.Name,
                Notes    = createFolderRequest.Notes
            };

            return(apiCreateFolderRequest);
        }
Example #18
0
        public override Task <CreateFolderReply> CreateFolder(CreateFolderRequest request, ServerCallContext context)
        {
            var    result    = new CreateFolderReply();
            string listTitle = GetDocumentListTitle(request.EntityName);

            SharePointFileManager _sharePointFileManager = new SharePointFileManager(_configuration);

            CreateDocumentLibraryIfMissing(listTitle, GetDocumentTemplateUrlPart(request.EntityName));

            bool folderExists = false;

            try
            {
                var folder = _sharePointFileManager.GetFolder(listTitle, request.FolderName).GetAwaiter().GetResult();
                if (folder != null)
                {
                    folderExists = true;
                }
            }
            catch (Exception)
            {
                folderExists = false;
            }

            if (folderExists)
            {
                result.ResultStatus = ResultStatus.Success;
            }
            else
            {
                try
                {
                    _sharePointFileManager.CreateFolder(GetDocumentListTitle(request.EntityName), request.FolderName).GetAwaiter().GetResult();
                    var folder = _sharePointFileManager.GetFolder(listTitle, request.FolderName).GetAwaiter().GetResult();
                    if (folder != null)
                    {
                        result.ResultStatus = ResultStatus.Success;
                    }
                }
                catch (SharePointRestException ex)
                {
                    result.ResultStatus = ResultStatus.Fail;
                    result.ErrorDetail  = $"ERROR in creating folder {request.FolderName}";
                    _logger.LogError(ex, result.ErrorDetail);
                }
                catch (Exception e)
                {
                    result.ResultStatus = ResultStatus.Fail;
                    result.ErrorDetail  = $"ERROR in creating folder {request.FolderName}";
                    _logger.LogError(e, result.ErrorDetail);
                }
            }

            return(Task.FromResult(result));
        }
Example #19
0
        public void CreateFolder_Success()
        {
            CreateFolderRequest folderRequest = createFolderRequest();
            var result = controller.CreateFolder(folderRequest);

            Assert.IsNotNull(result);
            Assert.IsInstanceOfType(result, typeof(OkNegotiatedContentResult <CreateFolderResponse>));
            var unwrappedResult = result as OkNegotiatedContentResult <CreateFolderResponse>;

            Assert.AreEqual(unwrappedResult.Content.Data, 1);
            Assert.AreEqual(unwrappedResult.Content.Success, ResponseStatus.Succeeded);
        }
        /// <summary>
        /// Create a new folder within the specified category.
        ///
        /// c.f. https://developers.freshdesk.com/api/#solution_folder_attributes
        /// </summary>
        ///
        /// <param name="categoryId">
        /// The category within which the folder will be placed
        /// </param>
        ///
        /// <param name="request">
        /// An object specifying at least the name of the new folder.
        /// </param>
        ///
        /// <param name="cancellationToken"></param>
        ///
        /// <returns>The created folder object</returns>
        public async Task <Folder> CreateFolderAsync(
            long categoryId,
            CreateFolderRequest request,
            CancellationToken cancellationToken = default)
        {
            if (request == null)
            {
                throw new ArgumentNullException(nameof(request), "The request must not be null");
            }

            return(await _freshdeskClient.ApiOperationAsync <Folder>(HttpMethod.Post, $"/api/v2/solutions/categories/{categoryId}/folders", request, cancellationToken).ConfigureAwait(false));
        }
Example #21
0
        public static void Run()
        {
            var apiInstance = new FolderApi(Constants.GetConfig());

            try
            {
                var request = new CreateFolderRequest("", Constants.MyStorage);

                apiInstance.CreateFolder(request);
                Console.WriteLine("Expected response type is Void: 'Annotationdocs' folder created.");
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception while calling FolderApi: " + e.Message);
            }
        }
        public async Task CreateFolderAsync(CreateFolderRequest request)
        {
            using var context = GetSharePointOnlineContext(request.SiteUrl);
            var list   = context.Web.GetListByTitle(request.ListName);
            var folder = await list.RootFolder.EnsureFolderAsync(request.FolderName);

            if (request.IsSharing)
            {
                var urlToDocument = $"{AppConfigurations.SpoUrl}{folder.ServerRelativeUrl}";
                await context.Web.ShareDocumentAsync(
                    urlToDocument,
                    request.TargerEmailToShare,
                    request.SharingOption.ExternalSharing(),
                    sendEmail : false);
            }
        }
Example #23
0
        public void ToApiCreateFolderRequest()
        {
            // ARRANGE
            ApiCreateFolderRequest expected = FactoryFolder.ApiCreateFolderRequest;

            CreateFolderRequest param = new CreateFolderRequest(expected.ParentId, expected.Name)
            {
                Notes = expected.Notes
            };

            // ACT
            ApiCreateFolderRequest actual = FolderMapper.ToApiCreateFolderRequest(param);

            // ASSERT
            Assert.Equal(expected, actual, new ApiCreateFolderRequestComparer());
        }
        public static void Run()
        {
            var configuration = new Configuration(Common.MyAppSid, Common.MyAppKey);
            var apiInstance   = new FolderApi(configuration);

            try
            {
                var request = new CreateFolderRequest("", Common.MyStorage);

                apiInstance.CreateFolder(request);
                Console.WriteLine("Expected response type is Void: 'Comparisondocs' folder created.");
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception while calling FolderApi: " + e.Message);
            }
        }
Example #25
0
        public Node CreateFolder(CreateFolderRequest request)
        {
            _client.Executor.CheckApiServerVersion();

            #region Parameter Validation

            request.MustNotNull(nameof(request));
            request.ParentId.MustPositive(nameof(request.ParentId));
            request.Name.MustNotNullOrEmptyOrWhitespace(nameof(request.Name));

            #endregion

            ApiCreateFolderRequest apiCreateFolderRequest = FolderMapper.ToApiCreateFolderRequest(request);
            IRestRequest           restRequest            = _client.Builder.PostFolder(apiCreateFolderRequest);
            ApiNode result = _client.Executor.DoSyncApiCall <ApiNode>(restRequest, RequestType.PostFolder);
            return(NodeMapper.FromApiNode(result));
        }
        /// <summary>
        /// Given a folder, this creates a translation of that folder into the
        /// requested language code.
        ///
        /// c.f. https://developers.freshdesk.com/api/#solution_folder_attributes
        /// </summary>
        ///
        /// <param name="folderId">
        /// The unique identifier for the folder
        /// </param>
        ///
        /// <param name="languageCode">
        /// The language code (e.g. es) which the translation corresponds to.
        /// </param>
        ///
        /// <param name="request">
        /// Encapsulates the new translation information.
        /// </param>
        ///
        /// <param name="cancellationToken"></param>
        ///
        /// <returns>The translated folder</returns>
        public async Task <Folder> CreateFolderTranslationAsync(
            long folderId,
            string languageCode,
            CreateFolderRequest request,
            CancellationToken cancellationToken = default)
        {
            if (request == null)
            {
                throw new ArgumentNullException(nameof(request), "The request must not be null");
            }
            if (string.IsNullOrWhiteSpace(languageCode))
            {
                throw new ArgumentOutOfRangeException(nameof(languageCode), languageCode, "Language code must be set to something");
            }

            return(await _freshdeskClient.ApiOperationAsync <Folder>(HttpMethod.Post, $"/api/v2/solutions/folders/{folderId}/{languageCode}", request, cancellationToken).ConfigureAwait(false));
        }
Example #27
0
        public int Add(CreateFolderRequest folder)
        {
            if (folder == null)
            {
                throw new NsiArgumentException(ExceptionMessages.ArgumentException);
            }
            FolderDomain folderDomain = new FolderDomain
            {
                DateCreated    = DateTime.Now,
                Name           = folder.Name,
                ParentFolderId = folder.ParentFolderId
            };

            if (!Exists(folder.ParentFolderId) && folder.ParentFolderId != 0)
            {
                throw new NsiArgumentException(ExceptionMessages.ArgumentException);
            }
            return(_folderRepository.Add(folderDomain));
        }
Example #28
0
        /// <summary>
        /// Create the folder
        /// </summary>
        /// <param name="request">Request. <see cref="CreateFolderRequest" /></param>
        /// <returns><see cref=""/></returns>
        public void CreateFolder(CreateFolderRequest request)
        {
            // verify the required parameter 'path' is set
            if (request.path == null)
            {
                throw new ApiException(400, "Missing required parameter 'path' when calling CreateFolder");
            }

            // create path and map variables
            var resourcePath = this.configuration.GetApiRootUrl() + "/ocr/storage/folder/{path}";

            resourcePath = Regex
                           .Replace(resourcePath, "\\*", string.Empty)
                           .Replace("&amp;", "&")
                           .Replace("/?", "?");
            resourcePath = UrlHelper.AddPathParameter(resourcePath, "path", request.path);
            resourcePath = UrlHelper.AddQueryParameterToUrl(resourcePath, "storageName", request.storageName);

            try
            {
                var response = this.apiInvoker.InvokeApi(
                    resourcePath,
                    "PUT",
                    null,
                    null,
                    null);
                if (response != null)
                {
                    return;
                }

                return;
            }
            catch (ApiException ex)
            {
                if (ex.ErrorCode == 404)
                {
                    return;
                }

                throw;
            }
        }
Example #29
0
        public void TestCopyMoveFolder()
        {
            // Create temp folder
            var cRequest = new CreateFolderRequest("temp");

            FolderApi.CreateFolder(cRequest);

            // Copy folder
            var copyRequest = new CopyFolderRequest("temp", "temp1");

            FolderApi.CopyFolder(copyRequest);

            // Check copied folder
            var eRequest  = new ObjectExistsRequest("temp1");
            var eResponse = StorageApi.ObjectExists(eRequest);

            Assert.IsTrue(eResponse.Exists);
            Assert.IsTrue(eResponse.IsFolder);

            // Copy folder
            var moveRequest = new MoveFolderRequest("temp1", "temp2");

            FolderApi.MoveFolder(moveRequest);

            // Check moved folder
            eRequest  = new ObjectExistsRequest("temp1");
            eResponse = StorageApi.ObjectExists(eRequest);
            Assert.IsFalse(eResponse.Exists);
            eRequest  = new ObjectExistsRequest("temp2");
            eResponse = StorageApi.ObjectExists(eRequest);
            Assert.IsTrue(eResponse.Exists);

            // Delete temp and temp2 folders
            var delRequest = new DeleteFolderRequest("temp", null, true);

            FolderApi.DeleteFolder(delRequest);
            delRequest = new DeleteFolderRequest("temp2", null, true);
            FolderApi.DeleteFolder(delRequest);
        }
        public async Task <IActionResult> Create([FromBody] CreateFolderRequest request)
        {
            if (_invalidName.IsMatch(request.Name?.Trim() ?? string.Empty))
            {
                Log.Error($"Invalid folder name {request.Name}");
                return(BadRequest());
            }

            Guid folderId      = Guid.NewGuid();
            Guid correlationId = Guid.Empty;

            Log.Information($"Creating folder with Id: {folderId}, ParentId: {request.ParentId}, Name: {request.Name}, UserId: {UserId}");

            await _bus.Publish <CreateFolder>(new
            {
                Id       = folderId,
                UserId   = UserId,
                Name     = request.Name,
                ParentId = request.ParentId
            });

            return(AcceptedAtRoute("GetSingleEntity", new { type = "folders", id = folderId }, null));
        }