public ActionResult <Folder> PostFolder(Folder folder)
        {
            _folderRepository.Add(folder);
            _folderRepository.SaveChanges();

            return(CreatedAtAction(nameof(GetFolder), new { id = folder.Id }, folder));
        }
        public async Task Handle(SaveFolderCommand command)
        {
            var model = command.Model;

            if (model.Id == Guid.Empty)
            {
                throw new InvalidOperationException($"Model '{model.Name}' has empty id");
            }

            var folder = await folderRepository.Get(model.Id);

            if (folder != null)
            {
                folder.ChangeName(model.Name);
                folder.ChangeColor(new Color(model.Color));

                await folderRepository.Update(folder);

                eventBus.Publish(new FolderUpdatedEvent(model));
            }
            else
            {
                folder = model.ToEntity();
                await folderRepository.Add(folder);

                eventBus.Publish(new FolderAddedEvent(model));
            }
        }
 private void AddFolder(string obj, int i)
 {
     FolderRepository.Add(new FolderDTO()
     {
         Name = obj, ParentId = i
     });
 }
Beispiel #4
0
        public DtoFolder AddFolder(DtoFolder parent, string newFolderName)
        {
            var folder = folderRepository.Add(parent.ToDalFolder(), newFolderName);

            uow.Commit();

            return(folder.ToDtoFolder());
        }
 private void addFoldersToRepository(IFolderRepository folderRepository, int numberOfFoldersToAdd)
 {
     for (int i = 0; i < numberOfFoldersToAdd; i++) {
     folderRepository.Add(new Folder() {
       Name = "Test Folder " + i,
       ParentFolderId = 0,
       Path = System.Environment.CurrentDirectory
     });
       }
 }
Beispiel #6
0
        public IActionResult Create([FromBody] Folder item)
        {
            if (item == null)
            {
                return(BadRequest());
            }

            var userId = _userManager.GetUserId(HttpContext.User);

            if (_permissionServices.HasWriteAccess(item.ProjectID, userId))
            {
                return(new UnauthorizedResult());
            }

            _folderRepository.Add(item);
            return(CreatedAtAction("GetFolder", new { id = item.Id }, item));
        }
        private void TryAdd(Content content)
        {
            if (TryCastToFile(content, out File file))
            {
                _fileRepository.Add(file);
            }
            else if (TryCastToFolder(content, out Folder folder))
            {
                _folderRepository.Add(folder);
            }
            else
            {
                throw new ArgumentException($"{nameof(content)} is an unsupported content type.");
            }

            AddObject(content);
        }
Beispiel #8
0
        public void Register(RegistrationUserDTO user, string password)//User u, string password)
        {
            var    u    = Mapper.Map <User>(user);
            string salt = GenerateSalt(64);
            string hash = GenerateHash(password, salt);

            u.Salt     = salt;
            u.PassHash = hash;

            Folder privateFolder = CreateRootFolder(u);

            _users.Add(u);
            _folders.Add(privateFolder);
            _roles.AddRoleToUser(Role.Default, u);
            _users.SaveChanges();
            _folders.SaveChanges();
            _roles.SaveChanges();
        }
Beispiel #9
0
        public int AddFolder(int userId, int parentId, string folderName)
        {
            var user         = _users.GetById(userId);
            var parentFolder = _folders.GetById(parentId);
            //if (!_verifier.IsAccessibleByVisibility(parentId, folderName))
            //    return -1;
            Folder f = new Folder()
            {
                CreationTime = DateTime.Now,
                Name         = folderName,
                ParentFolder = parentFolder,
                Visibility   = FileAccess.Private //,
                                                  //User = user
            };

            _folders.Add(f);
            _folders.SaveChanges();
            return(f.Id);
        }
Beispiel #10
0
        public void CreateFolder(int?rootFolderId, string folderName, string userName)
        {
            var user = _userService.GetUserByName(userName);

            if (rootFolderId != null)
            {
                VerifyUserHaveFolder(user.Id, rootFolderId);
            }
            var dalFolder = new DalAppFolder()
            {
                Name         = folderName,
                DateUploaded = DateTime.Now,
                RootFolderId = rootFolderId,
                UserId       = user.Id
            };

            _folderRepository.Add(dalFolder);
            _unitOfWork.Commit();
        }
Beispiel #11
0
        public IActionResult Create(Folder model)
        {
            _logger.LogInformation("Log message in the Create() POST method");
            if (ModelState.IsValid)
            {
                _logger.LogInformation("Adding New Folder");
                Folder newFolder = new Folder
                {
                    Name           = model.Name,
                    ParentFolderId = model.ParentFolderId,
                };

                _folderRepository.Add(newFolder);
                _logger.LogInformation("New Folder Added");
                return(RedirectToAction("index"));
            }
            ViewBag.Folders = _folderRepository.GetAllFolders().ToList();
            return(View());
        }
Beispiel #12
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));
        }
        public void CreateFolder(FolderDto FolderDto)
        {
            var folderToCreate = _folderRepository.GetBy(FolderDto.ID);

            _folderRepository.Add(folderToCreate);
        }