public async Task<ActionResult> Create(Guid id) { var grupo = await this.grupoPreguntasService.GetAsync(id); var nextOrden = grupo.Preguntas.Count > 0 ? grupo.Preguntas.Max(p => p.Orden) + 1 : 1; var model = new PreguntaViewModel { Habilitado = true, GrupoId = id, Orden = nextOrden }; return this.View(model); }
public async Task<ActionResult> Edit(PreguntaViewModel model) { if (ModelState.IsValid) { await this.preguntasService.CreateOrUpdateAsync(model); return this.RedirectToAction("Details", "Grupos", new { id = model.GrupoId }); } // If we got this far, something failed, redisplay form return this.View(model); }