public void FileCreate_ToDLModelShouldMapToFile() { var newFile = new FileCreate { FileDescription = "asdf", PilotID = 1, UserID = 1, FileName = "file.txt", ParsedID = "parsedid" }; var result = newFile.ToDLModel(); Assert.Equal(newFile.FileDescription, result.FileDescription); Assert.Equal(newFile.PilotID, result.PilotID); Assert.Equal(newFile.UserID, result.UploaderID); Assert.Equal(newFile.FileName, result.FileName); Assert.Equal(newFile.ParsedID, result.ParsedID); }
public IActionResult Create([FromForm] FileCreate apiModel) { BlobContainerClient containerClient = _blobSC.GetBlobContainerClient($"pilot{apiModel.PilotID}"); if (!containerClient.Exists()) { containerClient = _blobSC.CreateBlobContainer($"pilot{apiModel.PilotID}", Azure.Storage.Blobs.Models.PublicAccessType.BlobContainer); } BlobClient blobClient = containerClient.GetBlobClient(apiModel.FileName); if (blobClient.Exists()) { return(BadRequest(new { error = "File name already taken for this pilot" })); } blobClient.Upload(apiModel.File.OpenReadStream()); apiModel.FileURL = blobClient.Uri.AbsoluteUri; return(Ok(FileMinimal.FromDLModel(_aviBL.AddFile(apiModel.ToDLModel())))); }