public async Task <IActionResult> Add([FromForm] CarImageDto imageDto, List <IFormFile> files)
        {
            var result = await _carImageService.AddAsync(_mapper.Map <CarImage>(imageDto), files);

            if (result.Success)
            {
                return(Created("", result));
            }
            return(BadRequest());
        }
示例#2
0
        public async Task <IActionResult> AddAsync(int carId, List <IFormFile> formFiles)
        {
            if (formFiles.Count == 0)
            {
                return(BadRequest(Messages.CarImageCountInvalid));
            }

            IResult lastAddResult = new ErrorResult();

            foreach (var formFile in formFiles)
            {
                var addResult = await _carImageService.AddAsync(new CarImageAddDto()
                {
                    CarId = carId, FormFile = formFile
                });

                lastAddResult = addResult;
                if (!addResult.Success)
                {
                    return(BadRequest(addResult));
                }
            }
            return(Ok(lastAddResult));
        }