Esempio n. 1
0
        public async Task AddPostAsync(AddRequestDto addRequest)
        {
            var filePath = string.Empty;
            var fileSnapshotImagePath = string.Empty;

            // todo dodaj && addRequest.UserNickname != null jak bedzie logowanie
            if (addRequest.EncodedFile != null && addRequest.FileName != null)
            {
                var encryptedFile = new EncryptedFile(addRequest);
                await encryptedFile.DecryptAndSaveFile();

                encryptedFile.GenerateAndSaveSnapshot();
                filePath = encryptedFile.FilePath;
                fileSnapshotImagePath = encryptedFile.SnapshotImagePath;
            }

            var post = new Post(
                addRequest.Title.ToLower().RemoveDiacritics(),
                addRequest.Description.ToLower().RemoveDiacritics(),
                addRequest.School,
                addRequest.MaterialType,
                fileSnapshotImagePath,
                filePath,
                addRequest.UserNickname);

            await this.postRepository.AddAsync(post);
        }