/// <inheritdoc /> public async Task <GoverningBodyDocumentsDTO> AddGoverningBodyDocumentAsync(GoverningBodyDocumentsDTO documentDto) { var fileBase64 = documentDto.BlobName.Split(',')[1]; var extension = $".{documentDto.FileName.Split('.').LastOrDefault()}"; var fileName = $"{_uniqueId.GetUniqueId()}{extension}"; await _governingBodyFilesBlobStorage.UploadBlobForBase64Async(fileBase64, fileName); documentDto.BlobName = fileName; var documentTypes = await GetAllGoverningBodyDocumentTypesAsync(); documentDto.GoverningBodyDocumentType = documentTypes .FirstOrDefault(dt => dt.Name == documentDto.GoverningBodyDocumentType.Name); documentDto.GoverningBodyDocumentTypeId = documentDto.GoverningBodyDocumentType.Id; var document = _mapper.Map <GoverningBodyDocumentsDTO, GoverningBodyDocuments>(documentDto); _repositoryWrapper.GoverningBodyDocuments.Attach(document); await _repositoryWrapper.GoverningBodyDocuments.CreateAsync(document); await _repositoryWrapper.SaveAsync(); return(documentDto); }
public async Task <IActionResult> AddDocument(GoverningBodyDocumentsDTO document) { await _governingBodyDocumentsService.AddGoverningBodyDocumentAsync(document); _logger.LogInformation($"Document with id {{{document.Id}}} was added."); return(Ok(document)); }