public ActionResult TerminarComRedirect(string IDRiscosDoEstabelecimento)
        {
            try
            {
                AtividadesDoEstabelecimento oRiscosDoEstabelecimento = AtividadesDoEstabelecimentoBusiness.Consulta.FirstOrDefault(p => p.IDEstabelecimentoImagens.Equals(IDRiscosDoEstabelecimento));
                if (oRiscosDoEstabelecimento == null)
                {
                    return(Json(new { resultado = new RetornoJSON()
                                      {
                                          Erro = "Não foi possível excluir a imagem  '" + oRiscosDoEstabelecimento.NomeDaImagem + "', pois a mesma não foi localizada."
                                      } }));
                }
                else
                {
                    //oEmpresa.DataExclusao = DateTime.Now;
                    oRiscosDoEstabelecimento.UsuarioExclusao = "LoginTeste";

                    AtividadesDoEstabelecimentoBusiness.Alterar(oRiscosDoEstabelecimento);

                    TempData["MensagemSucesso"] = "A imagem '" + oRiscosDoEstabelecimento.NomeDaImagem + "' foi excluída com sucesso.";

                    return(Json(new { resultado = new RetornoJSON()
                                      {
                                          URL = Url.Action("Index", "RiscosDoEstabelecimento")
                                      } }));
                }
            }
            catch (Exception ex)
            {
                if (ex.GetBaseException() == null)
                {
                    return(Json(new { resultado = new RetornoJSON()
                                      {
                                          Erro = ex.Message
                                      } }));
                }
                else
                {
                    return(Json(new { resultado = new RetornoJSON()
                                      {
                                          Erro = ex.GetBaseException().Message
                                      } }));
                }
            }
        }
示例#2
0
        public ActionResult Cadastrar(AtividadesDoEstabelecimento oAtividadesDoEstabelecimento, string RegistroID, string EstabID)
        {
            oAtividadesDoEstabelecimento.IDEstabelecimentoImagens = Guid.Parse(RegistroID);
            oAtividadesDoEstabelecimento.IDEstabelecimento        = Guid.Parse(EstabID);

            if (ModelState.IsValid)
            {
                try
                {
                    AtividadesDoEstabelecimentoBusiness.Inserir(oAtividadesDoEstabelecimento);

                    Extensions.GravaCookie("MensagemSucesso", "A imagem '" + oAtividadesDoEstabelecimento.Imagem + "'foi cadastrada com sucesso.", 10);



                    return(Json(new { resultado = new RetornoJSON()
                                      {
                                          URL = Url.Action("Novo", "AtividadesDoEstabelecimento", new { id = oAtividadesDoEstabelecimento.IDEstabelecimentoImagens })
                                      } }));
                }
                catch (Exception ex)
                {
                    if (ex.GetBaseException() == null)
                    {
                        return(Json(new { resultado = new RetornoJSON()
                                          {
                                              Erro = ex.Message
                                          } }));
                    }
                    else
                    {
                        return(Json(new { resultado = new RetornoJSON()
                                          {
                                              Erro = ex.GetBaseException().Message
                                          } }));
                    }
                }
            }
            else
            {
                return(Json(new { resultado = TratarRetornoValidacaoToJSON() }));
            }
        }
示例#3
0
        public ActionResult Cadastrar(AtividadesDoEstabelecimento oAtividadesDoEstabelecimentoBusiness, string IDAtividadesDoEstabelecimento)
        {
            oAtividadesDoEstabelecimentoBusiness.ID = Guid.Parse(IDAtividadesDoEstabelecimento);
            //oMedidasDeControleExistentes.IDAtividadeRiscos = AtivRiscoID;

            if (ModelState.IsValid)
            {
                try
                {
                    AtividadesDoEstabelecimentoBusiness.Inserir(oAtividadesDoEstabelecimentoBusiness);

                    Extensions.GravaCookie("MensagemSucesso", "A imagem '" + oAtividadesDoEstabelecimentoBusiness.NomeDaImagem + "'foi cadastrada com sucesso.", 10);



                    return(Json(new { resultado = new RetornoJSON()
                                      {
                                          URL = Url.Action("Novo", "MedidasDeControle", new { id = oAtividadesDoEstabelecimentoBusiness.ID })
                                      } }));
                }
                catch (Exception ex)
                {
                    if (ex.GetBaseException() == null)
                    {
                        return(Json(new { resultado = new RetornoJSON()
                                          {
                                              Erro = ex.Message
                                          } }));
                    }
                    else
                    {
                        return(Json(new { resultado = new RetornoJSON()
                                          {
                                              Erro = ex.GetBaseException().Message
                                          } }));
                    }
                }
            }
            else
            {
                return(Json(new { resultado = TratarRetornoValidacaoToJSON() }));
            }
        }
示例#4
0
        public ActionResult Terminar(string IDRiscosDoEstabelecimento)
        {
            try
            {
                AtividadesDoEstabelecimento oRiscosDoEstabelecimento = AtividadesDoEstabelecimentoBusiness.Consulta.FirstOrDefault(p => p.IDEstabelecimentoImagens.Equals(IDRiscosDoEstabelecimento));
                if (oRiscosDoEstabelecimento == null)
                {
                    return(Json(new { resultado = new RetornoJSON()
                                      {
                                          Erro = "Não foi possível excluir a empresa, pois a mesma não foi localizada."
                                      } }));
                }
                else
                {
                    //oEmpresa.DataExclusao = DateTime.Now;
                    oRiscosDoEstabelecimento.UsuarioExclusao = CustomAuthorizationProvider.UsuarioAutenticado.Login;
                    AtividadesDoEstabelecimentoBusiness.Alterar(oRiscosDoEstabelecimento);

                    return(Json(new { resultado = new RetornoJSON()
                                      {
                                          Sucesso = "A imagem '" + oRiscosDoEstabelecimento.NomeDaImagem + "' foi excluída com sucesso."
                                      } }));
                }
            }
            catch (Exception ex)
            {
                if (ex.GetBaseException() == null)
                {
                    return(Json(new { resultado = new RetornoJSON()
                                      {
                                          Erro = ex.Message
                                      } }));
                }
                else
                {
                    return(Json(new { resultado = new RetornoJSON()
                                      {
                                          Erro = ex.GetBaseException().Message
                                      } }));
                }
            }
        }
示例#5
0
        public ActionResult Ativar(AtividadesDoEstabelecimento oRiscosDoEstabelecimento)
        {
            if (ModelState.IsValid)
            {
                //var AdmissaoID = oRiscosDoEstabelecimento.Alocacao.IdAdmissao;
                try
                {
                    AtividadesDoEstabelecimentoBusiness.Alterar(oRiscosDoEstabelecimento);

                    Extensions.GravaCookie("MensagemSucesso", "A imagem '" + oRiscosDoEstabelecimento.NomeDaImagem + "' foi atualizada com sucesso.", 10);



                    return(Json(new { resultado = new RetornoJSON()
                                      {
                                          URL = Url.Action("Novo", "Alocacao", new {  })
                                      } }));
                }
                catch (Exception ex)
                {
                    if (ex.GetBaseException() == null)
                    {
                        return(Json(new { resultado = new RetornoJSON()
                                          {
                                              Erro = ex.Message
                                          } }));
                    }
                    else
                    {
                        return(Json(new { resultado = new RetornoJSON()
                                          {
                                              Erro = ex.GetBaseException().Message
                                          } }));
                    }
                }
            }
            else
            {
                return(Json(new { resultado = TratarRetornoValidacaoToJSON() }));
            }
        }
        public ActionResult Atualizar(AtividadesDoEstabelecimento oRiscosDoEstabelecimento)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    AtividadesDoEstabelecimentoBusiness.Alterar(oRiscosDoEstabelecimento);

                    TempData["MensagemSucesso"] = "A imagem '" + oRiscosDoEstabelecimento.NomeDaImagem + "' foi atualizada com sucesso.";

                    return(Json(new { resultado = new RetornoJSON()
                                      {
                                          URL = Url.Action("Index", "RiscosDoEstabelecimento")
                                      } }));
                }
                catch (Exception ex)
                {
                    if (ex.GetBaseException() == null)
                    {
                        return(Json(new { resultado = new RetornoJSON()
                                          {
                                              Erro = ex.Message
                                          } }));
                    }
                    else
                    {
                        return(Json(new { resultado = new RetornoJSON()
                                          {
                                              Erro = ex.GetBaseException().Message
                                          } }));
                    }
                }
            }
            else
            {
                return(Json(new { resultado = TratarRetornoValidacaoToJSON() }));
            }
        }