public JsonResult Excluir(string id) { var item = Fabrica.EventoAplicacaoMongo().ListarPorId(id); if (item == null) { return(Json("", JsonRequestBehavior.AllowGet)); } Imagem.ExcluirArquivo(item.Arquivos, "evento"); Fabrica.EventoAplicacaoMongo().Excluir(id); return(Json("", JsonRequestBehavior.AllowGet)); }
public JsonResult Excluir(string id, string plugin, string idArquivo) { Arquivo arquivo, arquivoCapa; switch (plugin.ToLower()) { case "noticia": var noticia = Fabrica.NoticiaAplicacaoMongo().ListarPorId(id); arquivo = noticia.Arquivos.FirstOrDefault(x => x.Id == idArquivo); noticia.Arquivos.Remove(arquivo); Imagem.ExcluirArquivo(arquivo.Nome, plugin); noticia.Arquivos = Imagem.OrdenarArquivos(noticia.Arquivos.OrderBy(x => x.Ordem).Select(x => x.Id), noticia.Arquivos); arquivoCapa = noticia.Arquivos.FirstOrDefault(x => x.Ordem == 1); if (arquivoCapa != null) { Imagem.GeraArquivosBaseadoEmListaDeTamanhos(arquivoCapa.Nome, plugin, ImagensLayout.Noticias); } Fabrica.NoticiaAplicacaoMongo().Salvar(noticia); break; case "evento": var evento = Fabrica.EventoAplicacaoMongo().ListarPorId(id); arquivo = evento.Arquivos.FirstOrDefault(x => x.Id == idArquivo); evento.Arquivos.Remove(arquivo); Imagem.ExcluirArquivo(arquivo.Nome, plugin); evento.Arquivos = Imagem.OrdenarArquivos(evento.Arquivos.OrderBy(x => x.Ordem).Select(x => x.Id), evento.Arquivos); arquivoCapa = evento.Arquivos.FirstOrDefault(x => x.Ordem == 1); if (arquivoCapa != null) { Imagem.GeraArquivosBaseadoEmListaDeTamanhos(arquivoCapa.Nome, plugin, ImagensLayout.Eventos); } Fabrica.EventoAplicacaoMongo().Salvar(evento); break; } return(Json("", JsonRequestBehavior.AllowGet)); }