Reputation: 1
I have a model with a list, and I am trying to write a code to process the list, but nothing comes out. How can I fix or improve the method? I'm a beginner.
Code in model
public List<string> Poster { get; set; }
And my method
public async Task<ActionResult<int>> Post(News news){
if (!string.IsNullOrWhiteSpace(news.Poster))
{
var productPhoto = Convert.FromBase64String(news.Poster);
news.Poster = await _fileStorageService.SaveFile(productPhoto, "jpg", "news");
}
...
Upvotes: 0
Views: 60
Reputation: 45101
Your property Poster
is a list, but in your method you use it like a single string. I think you need to iterate over the list:
foreach(var entry in news.Poster)
{
if(!string.IsNullOrWhitespace(entry))
{
// ...
}
}
Upvotes: 1