Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        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);
        }