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); }
public async Task <IActionResult> Add([FromBody] AddGenreRequest request) { var response = await _genreManager.InsertAsync(request); if (response == null) { return(BadRequest("Failed To Add Genere")); } return(Ok(response)); }