public async Task <IActionResult> ChangeAdPhotos(int id, [FromForm] IFormFileCollection photos) { var acceptedExtensions = new[] { "jpg", "png", "jpeg", "bmp", "svg" }; foreach (var photo in photos) { if (!acceptedExtensions.Any(e => photo.FileName.EndsWith(e, StringComparison.CurrentCultureIgnoreCase))) { return(BadRequest( "The photo field only accepts files with the following extensions: .jpg, .png, .jpeg, .bmp, .svg")); } if (photo.Length > 3_000_000) { return(BadRequest("Too big file size!")); } } var userId = await GetCurrentUserId(); var result = await _advertisementService.ChangeAdPhotos(id, userId, photos); if (result.IsSuccessful) { return(Ok()); } return(StatusCode(500)); }