Example #1
0
        public ActionResult Cadastrar(CA oCA, string UKepi)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    Guid idepi = Guid.Parse(UKepi);
                    //Empresa.UsuarioInclusao = CustomAuthorizationProvider.UsuarioAutenticado.Login;
                    oCA.UsuarioInclusao = CustomAuthorizationProvider.UsuarioAutenticado.Login;
                    oCA.UKEpi           = idepi.ToString();

                    CABusiness.Inserir(oCA);

                    Extensions.GravaCookie("MensagemSucesso", "O CA '" + oCA.Numeros + "' foi cadastrado com sucesso.", 10);


                    return(Json(new { resultado = new RetornoJSON()
                                      {
                                          URL = Url.Action("Index", "CA")
                                      } }));
                }
                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() }));
            }
        }
Example #2
0
        public ActionResult Terminar(string IDCA)
        {
            try
            {
                Guid id  = Guid.Parse(IDCA);
                CA   oCA = CABusiness.Consulta.FirstOrDefault(p => string.IsNullOrEmpty(p.UsuarioExclusao) && p.ID.Equals(id));
                if (oCA == null)
                {
                    return(Json(new { resultado = new RetornoJSON()
                                      {
                                          Erro = "Não foi possível excluir a empresa, pois a mesma não foi localizada."
                                      } }));
                }
                else
                {
                    oCA.UsuarioExclusao = CustomAuthorizationProvider.UsuarioAutenticado.Login;
                    CABusiness.Terminar(oCA);

                    return(Json(new { resultado = new RetornoJSON()
                                      {
                                          Sucesso = "O CA '" + oCA.Numeros + "' foi excluído 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
                                      } }));
                }
            }
        }