示例#1
0
        public async Task <ActionResult> GetPhotoAsync(string id, [FromQuery] GetVehiclePhoto query)
        {
            query.Id = id;
            var result = await _queriesHanlder.Handle(query);

            if (result.Status != EStatusCode.Success)
            {
                return(NotFound(result));
            }
            return(File(result.Data.Bytes, "image/jpeg", result.Data.FileName));
        }
        public async void GetVehiclePhoto(
            EStatusCode expectedStatus,
            GetVehiclePhoto query,
            bool?withFile = false
            )
        {
            if (withFile.Value)
            {
                await CreateVehicleWithImageAsync(query.Id);
            }

            var(status, file) = await Request.DownloadFile(new Uri($"{Uri}/{query.Id}/photo"), $"{query.Id}.jpg", query);

            Assert.Equal(expectedStatus, status);
            if (expectedStatus == EStatusCode.Success)
            {
                Assert.NotNull(file);
                Assert.True(file.Exists);
            }
        }
 public GetVehiclePhotoController(GetVehicleById getVehicleById, GetVehiclePhoto getVehiclePhoto)
 {
     this.getVehicleById  = getVehicleById;
     this.getVehiclePhoto = getVehiclePhoto;
 }