public async Task <IActionResult> Create() { var genreList = await genre.GetAllAsync(); var model = new BopsDetailModel { Genres = genreList }; //dynamic modelNav = new NavBarViewModel //{ // BopModel = model //}; return(View(model)); }
public async Task <IActionResult> Create([FromForm] BopsDetailModel bopsDetail) { if (!ModelState.IsValid) { bopsDetail.Genres = await genre.GetAllAsync(); return(View("Create", bopsDetail)); } var artiste = await account.Find(x => x.Id == 1); var model = new Bop() { Artiste = artiste, ReleaseDate = DateTime.Parse(bopsDetail.ReleaseDate), Genre = await genre.Find(x => x.Id == bopsDetail.Genre), ReleaseVenue = "Lagos", BopName = bopsDetail.BopName, }; bop.Add(model); bop.Save(); return(RedirectToAction("Index", "Home")); }