Exemple #1
0
        public ActionResult Delete(int id, documento documento)
        {
            try
            {
                documento = DocumentoRepository.GetOne(id);

                if (ExistDependences(documento))
                {
                    return(View(documento));
                }

                if (!FileServerHelper.DeleteFile(documento.path))
                {
                    throw new Exception("Não foi possível salvar o arquivo");
                }
                else
                {
                    DocumentoRepository.Delete(documento);
                }

                return(RedirectToAction("List", new { message = "Dados excluídos com sucesso!" }));
            }
            catch
            {
                return(View());
            }
        }
Exemple #2
0
        public ActionResult Create(documento documento)
        {
            LoadFormJuri();

            try
            {
                if (validate(documento))
                {
                    return(View(documento));
                }

                if (UploadFile(ref documento))
                {
                    DocumentoRepository.Create(documento);
                    return(RedirectToAction("List", new { message = "Dados cadastrados com sucesso!" }));
                }
                else
                {
                    throw new Exception("Ocorreu um erro ao criar o registro");
                }
            }
            catch
            {
                if (!FileServerHelper.DeleteFile(documento.path))
                {
                    throw new Exception("Não foi possível excluir o arquivo");
                }
                else
                {
                    return(View(documento));
                }
            }
        }
Exemple #3
0
        public ActionResult Delete(string path, foto foto)
        {
            try
            {
                foto = FotoRepository.GetFotoById(path);

                if (!FileServerHelper.DeleteFile(Server.MapPath(foto.path)))
                {
                    throw new Exception("Não foi possível salvar o arquivo");
                }
                else
                {
                    FotoRepository.Delete(foto);
                }

                return(RedirectToAction("List", new { message = "Dados excluídos com sucesso!" }));
            }
            catch
            {
                return(View());
            }
        }