internal static object UpdateFolder(string id, FolderDAL newFolder)
        {
            Notes  notes        = new Notes();
            Folder targetFolder = Folder.AllFolders.FirstOrDefault(x => x.Id == id);

            if (targetFolder == null)
            {
                throw new NoteNotFound();
            }

            // Note moved
            if (newFolder.ParentId != null && targetFolder.ParentId != newFolder.ParentId)
            {
                Folder parent = Folder.AllFolders.Where(x => x.Id == newFolder.ParentId).FirstOrDefault();
                if (parent == null)
                {
                    throw new FolderNotFound();
                }

                targetFolder.Move(parent);
            }

            // Note renamed
            if (newFolder.Name != null && targetFolder.Name != newFolder.Name)
            {
                targetFolder.Rename(newFolder.Name);
            }

            return(targetFolder);
        }
        internal static Folder CreateFolder(FolderDAL newFolder)
        {
            var    notes  = new Notes();
            Folder parent = Folder.AllFolders.Where(x => x.Id == newFolder.ParentId).FirstOrDefault();

            if (parent == null)
            {
                throw new FolderNotFound();
            }
            return(parent.CreateFolder(newFolder));
        }
 public async Task <IActionResult> CreateFolder(FolderDAL newFolder)
 {
     try
     {
         return(Ok(FoldersService.CreateFolder(newFolder)));
     }
     catch (NoteAlreadyExistsException)
     {
         return(BadRequest("A Note with that name already exists."));
     }
 }
Exemple #4
0
        public static List <FolderDTO> GetNavigationByFolderIdAndUserId(int FolderId, int UserId)
        {
            List <FolderDTO> path      = new List <FolderDTO>();
            FolderDTO        folderDTO = null;

            while ((folderDTO = FolderDAL.GetFolderByFolderIdAndUserId(FolderId, UserId)) != null)
            {
                FolderId = folderDTO.ParentFolderId;
                path.Add(folderDTO);
            }
            return(path);
        }
 public async Task <IActionResult> UpdateFolder(string id, FolderDAL newFolder)
 {
     try
     {
         FoldersService.UpdateFolder(id, newFolder);
         return(Ok(new Notes().Root));
     }
     catch (NoteNotFound)
     {
         return(BadRequest("A note with that id doesn't exist"));
     }
 }
Exemple #6
0
 public static FolderDTO GetFolderByFolderIdAndUserId(int FolderId, int UserId)
 {
     return(FolderDAL.GetFolderByFolderIdAndUserId(FolderId, UserId));
 }
Exemple #7
0
 public static bool DeleteFolderByFolderIdAndUserId(int FolderId, int UserId)
 {
     return(FolderDAL.DeleteFolderByFolderIdAndUserId(FolderId, UserId));
 }
Exemple #8
0
 public static int CreateNewFolder(FolderDTO folderDTO)
 {
     return(FolderDAL.CreateNewFolder(folderDTO));
 }
Exemple #9
0
 public static List <FolderDTO> GetFoldersWithParentFolderNameByParentFolderIdAndUserId(int ParentFolderId, int UserId)
 {
     return(FolderDAL.GetFoldersWithParentFolderNameByParentFolderIdAndUserId(ParentFolderId, UserId));
 }
Exemple #10
0
 internal Folder CreateFolder(FolderDAL newFolder)
 {
     return(new Folder(newFolder.Name, Filepath, Id));
 }