예제 #1
0
        public ActionResult CadastrarTema(FormCollection formCollection)
        {
            if (formCollection.HasKeys())
            {
                int codDisciplina;
                int.TryParse(formCollection["ddlTemaDisciplina"], out codDisciplina);

                var codTemas = (from t in Repositorio.GetInstance().Tema
                                where t.CodDisciplina == codDisciplina
                                select t.CodTema).ToList();

                string[] temas = formCollection["txtTemaDescricao"].Split(';');
                int      i     = codTemas != null && codTemas.Count > 0 ? codTemas.Max() + 1 : 1;
                foreach (var item in temas)
                {
                    string tema = item.Trim();
                    if (!String.IsNullOrWhiteSpace(tema))
                    {
                        var t = new Tema();
                        t.CodDisciplina = codDisciplina;
                        t.CodTema       = i;
                        t.Descricao     = tema;
                        i++;
                        Tema.Inserir(t);
                    }
                }
            }
            return(RedirectToAction("Index"));
        }
예제 #2
0
        public ActionResult CadastrarDisciplina(FormCollection formCollection)
        {
            if (formCollection.HasKeys())
            {
                string disciplinaNome  = formCollection["txtDisciplina"];
                string disciplinaSigla = formCollection["txtSigla"];

                var disciplina = new Disciplina();
                disciplina.Descricao           = disciplinaNome;
                disciplina.Sigla               = disciplinaSigla;
                disciplina.FlagEletivaOptativa = (formCollection["chkEletivaOptativa"] != null) ? true : false;
                disciplina.FlagFlexivel        = (formCollection["chkFlexivel"] != null) ? true : false;

                int codDisciplina = Disciplina.Inserir(disciplina);

                string[] temas = formCollection["txtTema"].Split(';');
                int      i     = 1;
                foreach (var item in temas)
                {
                    string tema = item.Trim();
                    if (!String.IsNullOrWhiteSpace(tema))
                    {
                        var t = new Tema();
                        t.CodDisciplina = codDisciplina;
                        t.CodTema       = i;
                        t.Descricao     = tema;
                        i++;
                        Tema.Inserir(t);
                    }
                }
            }
            return(RedirectToAction("Index"));
        }