public async Task <IActionResult> AddTuristCity(CiudadViewmodel model) { if (this.ModelState.IsValid) { await this.turistaRepository.AddCiudadAsync(model); return(this.RedirectToAction("Details", new { id = model.TuristaId })); } return(this.View(model)); }
public async Task AddCiudadAsync(CiudadViewmodel model) { var turista = await this.GetTuristaWithCiudadAsync(model.TuristaId); if (turista == null) { return; } var agregar = new TuristaCiudad(); agregar.CiudadId = model.CiudadId; agregar.TuristaId = model.TuristaId; this.context.TuristaCiudades.Add(agregar); await this.context.SaveChangesAsync(); }
public async Task <IActionResult> AddTuristCity(int?id) { if (id == null) { return(NotFound()); } var turista = await this.turistaRepository.GetByIdAsync(id.Value); if (turista == null) { return(NotFound()); } var model = new CiudadViewmodel { TuristaId = turista.Id, Ciudades = this.ciudadRepository.GetComboCiudad() }; return(View(model)); }