public async Task <IActionResult> Create([Bind("FavoritosId,EventosId,UserId")] Favorito favorito) { if (ModelState.IsValid) { _context.Add(favorito); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["UserId"] = new SelectList(_context.AspNetUsers, "Id", "Id", favorito.UserId); return(View(favorito)); }
public async Task <IActionResult> Delete(int id, IFormCollection collection) { HttpClient client = _api.Initial(); HttpResponseMessage response = await client.DeleteAsync($"api/Eventos/{id}"); List <Favorito> listfavDelete = db.Favoritos.Where(x => x.EventosId == id.ToString()).ToList(); foreach (Favorito idfav in listfavDelete) { db.Favoritos.Remove(idfav); await db.SaveChangesAsync(); } return(View("ApagadoSucesso")); }