Пример #1
0
        public ActionResult Create(Pregunta pregunta)
        {
            ActionResult Result;

            try
            {
                if (ModelState.IsValid)
                {
                    PreguntasBLL oBLL = new PreguntasBLL();
                    oBLL.Create(pregunta);
                    Result = RedirectToAction("Index");
                }
                else
                {
                    Result = View(pregunta);
                }
                return(Result);
            }
            catch (Exception e)
            {
                return(View(pregunta));
            }
        }
Пример #2
0
        public ActionResult Create(Pregunta pregunta, VMPregunta vMPregunta)
        {
            var selectedTemas = vMPregunta.SelectedTemas;

            ActionResult Result;

            try
            {
                if (selectedTemas != null)
                {
                    foreach (var temaid in selectedTemas)
                    {
                        PreguntaTemasBLL mBLL = new PreguntaTemasBLL();
                        PreguntaTema     tema = new PreguntaTema();
                        tema.TemaID     = int.Parse(temaid);
                        tema.PreguntaID = pregunta.PreguntaID;
                        pregunta.PreguntaTemas.Add(tema);
                    }
                }
                if (ModelState.IsValid)
                {
                    PreguntasBLL oBLL = new PreguntasBLL();
                    oBLL.Create(pregunta);
                    return(RedirectToAction("Index"));
                }
                else
                {
                    Result = View(pregunta);
                }
                return(Result);
            }
            catch (Exception e)
            {
                return(View(pregunta));
            }
        }