Example #1
0
        public void Upload(AddFileCommand command)
        {
            AssertConcern.AssertArgumentNotEmpty(command.FileName, "Nome do arquivo não pode ser nulo");

            var fileAlreadyExist = FileRepository.GetFilesByQuery(command.FileName);

            var file = new File(command.FileName, command.ContentType)
            {
                Size        = command.File.Length,
                CreatedAt   = DateTime.UtcNow,
                CreateBy    = command.CreateUser,
                UpdatedAt   = DateTime.UtcNow,
                UpdateBy    = command.CreateUser,
                ReferenceId = command.ReferenceId.Value
            };

            file.GenerateNewId();

            FileRepository.Save(file, command.CreateUser);
            AzureContainer.AddFile($"{file.Id}_{file.Name}", command.File);

            Uow.Commit();
        }