public async Task <Document> SaveDocumentAsync(Stream fileStream, string fileName, long fileSize) { var id = Guid.NewGuid().ToString(); var fileLocation = await _contentStorage.SaveFile(fileStream, id + Path.GetExtension(fileName)); var documentsCount = _documentsRepository.GetDocumentsCount(); var document = new Document { Id = id, Name = fileName, FileSize = fileSize, Location = fileLocation, Position = documentsCount + 1 }; return(await _documentsRepository.AddDocumentAsync(document)); }