예제 #1
0
파일: Noticia.cs 프로젝트: josuecorrea/Eva
 public Noticia()
 {
     Data      = new DateTime();
     Arquivos  = new List <Arquivo>();
     Categoria = new Categoria();
     Local     = new Local();
     Fonte     = new Fonte();
     Zona      = new NoticiaZona();
 }
예제 #2
0
파일: Noticia.cs 프로젝트: josuecorrea/Eva
 public Noticia()
 {
     Data = new DateTime();
     Arquivos = new List<Arquivo>();
     Categoria = new Categoria();
     Local = new Local();
     Fonte = new Fonte();
     Zona = new NoticiaZona();
 }
예제 #3
0
        public ActionResult Editar(FonteViewModel fonte)
        {
            if (!ModelState.IsValid)
                return View(fonte);

            var fonteSalvar = new Fonte
            {
                Id = fonte.Id,
                Nome = fonte.Nome
            };

            fonteApp.Salvar(fonteSalvar);
            this.Flash("Fonte Salva com Sucesso!");
            return RedirectToAction("Index");
        }
예제 #4
0
        public ActionResult Editar(NoticiaViewModel noticia)
        {
            if (!ModelState.IsValid)
            {
                ViewBag.Categorias = categoriaApp.ListarTodos().ToList();
                ViewBag.Zonas = noticiaZonaApp.ListarTodos().ToList();
                return View(noticia);
            }

            var noticiaSalvar = new Noticia
            {
                Id = noticia.Id,
                Titulo = noticia.Titulo,
                Antetitulo = noticia.Antetitulo,
                Categoria = noticia.Categoria,
                Conteudo = noticia.Conteudo,
                Data = noticia.Data,
                ExibirComentarios = noticia.ExibirComentarios,
                Publicado = noticia.Publicado,
                Fonte = noticia.Fonte,
                Resumo = noticia.Resumo,
                Zona = noticia.Zona
            };

            noticiaSalvar.Categoria = categoriaApp.ListarPorId(noticia.CategoriaId);
            noticiaSalvar.Zona = noticiaZonaApp.ListarPorId(noticia.ZonaId);

            var fonte = fonteApp.ListarPorNome(noticia.FonteNome);
            if (fonte != null)
            {
                noticiaSalvar.Fonte = fonte;
            }
            else
            {
                var fonteNova = new Fonte() {Nome = noticia.FonteNome};
                fonteApp.Salvar(fonteNova);
                noticiaSalvar.Fonte = fonteNova;
            }

            noticiaApp.Salvar(noticiaSalvar);
            this.Flash("Noticia Salva com Sucesso!");
            return RedirectToAction("Index");
        }
예제 #5
0
 public void Salvar(Fonte entidade)
 {
     contexto.Save(entidade);
 }