private async Task <List <Genre> > GetGenres(List <AddGenreRequest> genres) { List <Genre> lstGenres = new List <Genre>(); string id = string.Empty; foreach (AddGenreRequest req in genres) { var genre = new Genre(); genre.Name = req.Name; genre.Description = req.Description; var res = await _genreManager.SearchAsync(new SearchRequest { fieldName = "Name", fieldValue = req.Name }); if (res == null) { await _genreManager.InsertAsync(req); res = await _genreManager.SearchAsync(new SearchRequest { fieldName = "Name", fieldValue = req.Name }); //id= req.id } genre.Id = res.Id; lstGenres.Add(genre); } return(lstGenres); }