コード例 #1
0
        public async Task <IActionResult> Upload(UploadFile model)
        {
            try
            {
                var file = model.File;
                if (file.Length <= 0)
                {
                    return(BadRequest());
                }

                var apiPath = await _filesService.UploadFile(file);

                var newPhoto = await _photosService.AddPhotoToFilmAsync(apiPath, model.FilmId);

                return(Ok(Mapper.Map <PhotoDTO, Photo>(newPhoto)));
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }
        }