private void fillProperties(classValidationQueryString objValidation, ref bool redirect)
        {
            objErro       = new classErro();
            lstEvaluation = new List <classEvaluation>();

            if (objValidation.lstQueryStrings.Count != 0)
            {
                //string valueInput = string.Empty;
                string strCustomerID = string.Empty;
                string strEvaluation = string.Empty;

                objValidation.getQueryParam("customerID", ref strCustomerID);
                objValidation.getQueryParam("cdEvaluation", ref strEvaluation);

                classClientes objCliente     = new classClientes();
                classClientes objClienteTemp = new classClientes();

                if (objCliente.getCustomerByID(ref objClienteTemp, Convert.ToInt32(strCustomerID)))
                {
                    this.objCustomer = objClienteTemp;

                    if (!string.IsNullOrEmpty(strCustomerID) && string.IsNullOrEmpty(strEvaluation))
                    {
                        listEvaluations();
                    }
                    else if (!string.IsNullOrEmpty(strEvaluation))
                    {
                        classEvaluation objEvaluation = new classEvaluation();
                        objEvaluation.id = Convert.ToInt32(strEvaluation);

                        if (objEvaluation.deleteByID())
                        {
                            redirect = true;
                        }
                        else
                        {
                            objErro = objEvaluation.objErro;
                            listEvaluations();
                        }
                    }
                    else
                    {
                        objErro.erro    = true;
                        objErro.strErro = "Erro ao receber parametros";
                    }
                }
                else
                {
                    objErro = objCliente.objErro;
                }
            }
            else
            {
                objErro.erro    = true;
                objErro.strErro = "Erro ao receber parametros";
            }
        }
Exemplo n.º 2
0
        public IActionResult OnGet(string strParams)
        {
            objErro = new classErro();
            var strErrorAuth = classModulo.strErrorAuth;

            try
            {
                if (!string.IsNullOrEmpty(strParams))
                {
                    var strObjValidation = classModulo.Decrypt(strParams);

                    var ObjValidation = JsonConvert.DeserializeObject <classValidationQueryString>(strObjValidation);

                    classErro objErroValidationUser = new classErro();

                    if (classModulo.userValidation(ObjValidation, ref objErroValidationUser, HttpContext.Session.GetObjectFromJson <classUsuario>("user")))
                    {
                        //execucao da logica da pagina
                        bool redirect = false;

                        fillProperties(ObjValidation, ref redirect);

                        if (redirect)
                        {
                            classValidationQueryString objValidationReturn = new classValidationQueryString();
                            objValidationReturn.objUsuario = HttpContext.Session.GetObjectFromJson <classUsuario>("user");
                            objValidationReturn.insertQueryParam("inpSearch", TempData["inpSearch"].ToString());

                            var strObjValidationReturn        = JsonConvert.SerializeObject(objValidationReturn);
                            var strObjValidationReturnEncrypt = classModulo.Encrypt(strObjValidationReturn);

                            return(RedirectToPage("customerPage", new { strParams = strObjValidationReturnEncrypt }));
                        }
                        return(Page());
                    }
                    else
                    {
                        return(RedirectToPage("index", new { objErroParam = JsonConvert.SerializeObject(objErroValidationUser) }));
                    }
                }
                else
                {
                    return(RedirectToPage("index", new { objErroParam = JsonConvert.SerializeObject(new classErro {
                            erro = true, strErro = strErrorAuth
                        }) }));
                }
            }
            catch (Exception e)
            {
                string a = e.Message;
                return(RedirectToPage("index", new { objErroParam = JsonConvert.SerializeObject(new classErro {
                        erro = true, strErro = strErrorAuth
                    }) }));
            }
        }
        public IActionResult OnPostDelete(int cdCustomer, int cdEvaluation)
        {
            classValidationQueryString objValidation = new classValidationQueryString();

            objValidation.objUsuario = HttpContext.Session.GetObjectFromJson <classUsuario>("user");

            TempData["cdCliente"] = cdCustomer;
            objValidation.insertQueryParam("cdEvaluation", cdEvaluation.ToString());
            objValidation.insertQueryParam("customerID", cdCustomer.ToString());

            var strObjValidation = JsonConvert.SerializeObject(objValidation);

            var strObjValidationEncrypt = classModulo.Encrypt(strObjValidation);

            return(RedirectToPage("customerEvaluationPage", new { strParams = strObjValidationEncrypt }));
        }
Exemplo n.º 4
0
        public IActionResult OnGet(int id, int cdCliente)
        {
            // Clientes
            if (id == (int)enumRedirect.customerPage)
            {
                classValidationQueryString objValidation = new classValidationQueryString();
                objValidation.objUsuario = HttpContext.Session.GetObjectFromJson <classUsuario>("user");
                var strObjValidation        = JsonConvert.SerializeObject(objValidation);
                var strObjValidationEncrypt = classModulo.Encrypt(strObjValidation);

                return(RedirectToPage("customerPage", new { strParams = strObjValidationEncrypt }));
            }

            if (id == (int)enumRedirect.newCustomerPage)
            {
                classValidationQueryString objValidation = new classValidationQueryString();

                objValidation.objUsuario = HttpContext.Session.GetObjectFromJson <classUsuario>("user");

                //objValidation.insertQueryParam("inpSearch", inpSearch);

                var strObjValidation = JsonConvert.SerializeObject(objValidation);

                var strObjValidationEncrypt = classModulo.Encrypt(strObjValidation);

                return(RedirectToPage("newCustomerPage", new { strParams = strObjValidationEncrypt }));
            }

            if (id == (int)enumRedirect.newCustomerEvaluationPage)
            {
                classValidationQueryString objValidation = new classValidationQueryString();

                objValidation.objUsuario = HttpContext.Session.GetObjectFromJson <classUsuario>("user");

                TempData["cdCliente"] = cdCliente;
                //objValidation.insertQueryParam("inpSearch", inpSearch);

                var strObjValidation = JsonConvert.SerializeObject(objValidation);

                var strObjValidationEncrypt = classModulo.Encrypt(strObjValidation);

                return(RedirectToPage("newCustomerEvaluationPage", new { strParams = strObjValidationEncrypt }));
            }

            return(Page());
        }
Exemplo n.º 5
0
        public IActionResult OnPostEdit(int id)
        {
            classValidationQueryString objValidation = new classValidationQueryString();

            objValidation.objUsuario = HttpContext.Session.GetObjectFromJson <classUsuario>("user");

            objValidation.insertQueryParam("id", id.ToString());

            var strObjValidation = JsonConvert.SerializeObject(objValidation);

            var strObjValidationEncrypt = classModulo.Encrypt(strObjValidation);

            return(RedirectToPage("newCustomerPage", new
            {
                strParams = strObjValidationEncrypt
            }));
        }
Exemplo n.º 6
0
        public IActionResult OnPost()
        {
            if (ModelState.IsValid)
            {
                classUsuario objUsuario = new classUsuario();

                if (objUsuario.getUserByName(inpUser))
                {
                    if (objUsuario.id == 0)
                    {
                        objUsuario.objErro.strErroAmigavel = "Usuario nao cadastrado";
                        objUsuario.objErro.erro            = true;
                        return(RedirectToPage("index", new { objErroParam = JsonConvert.SerializeObject(objUsuario.objErro) }));
                    }

                    else if (objUsuario.senha != inpPassword.Trim())
                    {
                        objUsuario.objErro.strErroAmigavel = "Senha incorreta!";
                        objUsuario.objErro.erro            = true;
                        return(RedirectToPage("index", new { objErroParam = JsonConvert.SerializeObject(objUsuario.objErro) }));
                    }
                    else
                    {
                        classValidationQueryString objValidation = new classValidationQueryString();

                        HttpContext.Session.SetObjectAsJson("user", objUsuario);
                        objValidation.objUsuario = HttpContext.Session.GetObjectFromJson <classUsuario>("user");

                        var strObjValidation = JsonConvert.SerializeObject(objValidation);

                        var strObjValidationEncrypt = classModulo.Encrypt(strObjValidation);

                        return(RedirectToPage("customerPage", new { strParams = strObjValidationEncrypt }));
                    }
                }
                else
                {
                    return(RedirectToPage("index", new { objErroParam = JsonConvert.SerializeObject(objUsuario.objErro) }));
                }
            }

            return(Page());
        }
Exemplo n.º 7
0
        public IActionResult OnPost()
        {
            if (!string.IsNullOrEmpty(inpSearch))
            {
                classValidationQueryString objValidation = new classValidationQueryString();

                objValidation.objUsuario = HttpContext.Session.GetObjectFromJson <classUsuario>("user");

                objValidation.insertQueryParam("inpSearch", inpSearch);

                var strObjValidation = JsonConvert.SerializeObject(objValidation);

                var strObjValidationEncrypt = classModulo.Encrypt(strObjValidation);

                TempData["inpSearch"] = inpSearch;

                return(RedirectToPage("customerPage", new { strParams = strObjValidationEncrypt }));
            }

            return(Page());
        }
Exemplo n.º 8
0
        //public IActionResult OnPostBackPage()
        //{

        //    classValidationQueryString objValidation = new classValidationQueryString();

        //    objValidation.objUsuario = HttpContext.Session.GetObjectFromJson<classUsuario>("user");

        //    //objValidation.insertQueryParam("inpSearch", inpSearch);

        //    var strObjValidation = JsonConvert.SerializeObject(objValidation);

        //    var strObjValidationEncrypt = classModulo.Encrypt(strObjValidation);

        //    return RedirectToPage("newCustomerPage", new { strParams = strObjValidationEncrypt });

        //}

        public IActionResult OnPost()
        {
            if (ModelState.IsValid)
            {
                classValidationQueryString objValidation = new classValidationQueryString();
                objErro = new classErro();

                classClientes objCliente = new classClientes();

                if (!userValidation(ref objCliente))
                {
                    objValidation.objUsuario = HttpContext.Session.GetObjectFromJson <classUsuario>("user");

                    objValidation.insertQueryParam("objErro", JsonConvert.SerializeObject(objErro));
                    objValidation.insertQueryParam("objCliente", JsonConvert.SerializeObject(objCliente));

                    var strObjValidation = JsonConvert.SerializeObject(objValidation);

                    var strObjValidationEncrypt = classModulo.Encrypt(strObjValidation);

                    return(RedirectToPage("newCustomerPage", new { strParams = strObjValidationEncrypt }));
                }
                else
                {
                    objValidation.objUsuario = HttpContext.Session.GetObjectFromJson <classUsuario>("user");

                    objValidation.insertQueryParam("objCliente", JsonConvert.SerializeObject(objCliente));

                    var strObjValidation = JsonConvert.SerializeObject(objValidation);

                    var strObjValidationEncrypt = classModulo.Encrypt(strObjValidation);

                    return(RedirectToPage("newCustomerPage", new { strParams = strObjValidationEncrypt }));
                }
            }

            return(Page());
        }
Exemplo n.º 9
0
        private void fillProperties(classValidationQueryString ObjValidation, ref bool redirect)
        {
            classPlanoSaude        objPlanoSaude     = new classPlanoSaude();
            List <classPlanoSaude> lstPlanoSaudeTemp = new List <classPlanoSaude>();

            if (objPlanoSaude.listPlanoSaude(ref lstPlanoSaudeTemp))
            {
                lstPlanoSaude = lstPlanoSaudeTemp.Select(c => new SelectListItem()
                {
                    Text = c.descricao, Value = c.codigo.ToString()
                }).ToList();

                if (ObjValidation.lstQueryStrings.Count != 0)
                {
                    string valueObjErro    = string.Empty;
                    string valueObjCliente = string.Empty;
                    string valueID         = string.Empty;

                    ObjValidation.getQueryParam("objErro", ref valueObjErro);
                    ObjValidation.getQueryParam("objCliente", ref valueObjCliente);
                    ObjValidation.getQueryParam("id", ref valueID);


                    if (!string.IsNullOrEmpty(valueObjErro))
                    {
                        objErro = JsonConvert.DeserializeObject <classErro>(valueObjErro);
                        classClientes objCliente = JsonConvert.DeserializeObject <classClientes>(valueObjCliente);

                        if (objCliente == null)
                        {
                            return;
                        }

                        fillForms(objCliente);
                    }
                    else if (!string.IsNullOrEmpty(valueObjCliente) && string.IsNullOrEmpty(valueObjErro))
                    {
                        classClientes objCliente = JsonConvert.DeserializeObject <classClientes>(valueObjCliente);

                        if (objCliente.insertAlterCliente())
                        {
                            if (objCliente.id == 0)
                            {
                                redirect = true;
                                TempData["alterSaveCustomerOK"] = "Cliente salvo com sucesso!";
                                TempData["inpSearch"]           = objCliente.nome;
                            }
                            else
                            {
                                redirect = true;
                                TempData["alterSaveCustomerOK"] = "Cliente alterado com sucesso!";
                            }
                        }
                        else
                        {
                            fillForms(objCliente);
                            objErro = objCliente.objErro;
                        }
                    }
                    else if (!string.IsNullOrEmpty(valueID) && string.IsNullOrEmpty(valueObjCliente) && string.IsNullOrEmpty(valueObjErro))
                    {
                        classClientes objCliente = new classClientes();

                        if (objCliente.getCustomerByID(ref objCliente, Convert.ToInt32(valueID)))
                        {
                            fillForms(objCliente);
                        }
                        else
                        {
                            objErro = objCliente.objErro;
                        }
                    }
                }
            }
            else
            {
                objErro = objPlanoSaude.objErro;
            }
        }
Exemplo n.º 10
0
        private void fillProperties(classValidationQueryString ObjValidation, ref bool redirect)
        {
            objErro     = new classErro();
            lstClientes = new List <classClientes>();

            if (ObjValidation.lstQueryStrings.Count != 0)
            {
                string valueInput = string.Empty;
                string valueID    = string.Empty;

                ObjValidation.getQueryParam("inpSearch", ref valueInput);
                ObjValidation.getQueryParam("id", ref valueID);

                if (!string.IsNullOrEmpty(valueInput))
                {
                    inpSearch = valueInput;

                    long cpf;
                    bool isCpf = long.TryParse(valueInput, out cpf);

                    if (!isCpf)
                    {
                        List <classClientes> lstClientesTemp = new List <classClientes>();
                        classClientes        objCliente      = new classClientes();

                        if (objCliente.listCustomerByName(ref lstClientesTemp, valueInput))
                        {
                            if (lstClientesTemp.Count == 0)
                            {
                                objCliente.objErro.erro            = true;
                                objCliente.objErro.strErroAmigavel = "Nenhum cliente encontrado com as palavras chaves: " + valueInput;
                                objErro = objCliente.objErro;
                            }
                            else
                            {
                                lstClientes = lstClientesTemp;
                            }
                        }
                        else
                        {
                            objErro = objCliente.objErro;
                        }
                    }
                    else
                    {
                        List <classClientes> lstClientesTemp = new List <classClientes>();
                        classClientes        objCliente      = new classClientes();

                        if (objCliente.listCustomerByCPF(ref lstClientesTemp, cpf.ToString()))
                        {
                            if (lstClientesTemp.Count == 0)
                            {
                                objCliente.objErro.erro            = true;
                                objCliente.objErro.strErroAmigavel = "Nenhum cliente encontrado com CPF: " + cpf;
                                objErro   = objCliente.objErro;
                                inpSearch = string.Empty;
                            }
                            else
                            {
                                lstClientes = lstClientesTemp;
                            }
                        }
                        else
                        {
                            objErro = objCliente.objErro;
                        }
                    }
                }
                else if (string.IsNullOrEmpty(valueInput) && !string.IsNullOrEmpty(valueID))
                {
                    classClientes objCliente = new classClientes();
                    objCliente.id = Convert.ToInt32(valueID);

                    if (objCliente.deleteCustomerByID())
                    {
                        redirect = true;
                    }
                    else
                    {
                        objErro = objCliente.objErro;
                    }
                }
            }
        }
Exemplo n.º 11
0
        private void fillProperties(classValidationQueryString ObjValidation, ref bool redirect)
        {
            var cd_cliente = Convert.ToInt32(TempData["cdCliente"].ToString());

            inpCdCliente = cd_cliente.ToString();

            TempData["cdCliente"] = cd_cliente;

            classClientes objCustomerTemp = new classClientes();
            classClientes objCustomer     = new classClientes();

            classTreatmentTypes        objTypes = new classTreatmentTypes();
            List <classTreatmentTypes> lstTypes = new List <classTreatmentTypes>();

            if (objTypes.list(ref lstTypes))
            {
                this.lstTypesTreatment = lstTypes.Select(c => new SelectListItem()
                {
                    Text = c.descricao, Value = c.codigo.ToString()
                }).ToList();

                if (objCustomer.getCustomerByID(ref objCustomerTemp, cd_cliente))
                {
                    this.objCustomer = objCustomerTemp;


                    string valueObjEvaluation = string.Empty;
                    string valueCdEvaluation  = string.Empty;

                    ObjValidation.getQueryParam("objEvaluation", ref valueObjEvaluation);
                    ObjValidation.getQueryParam("cdEvaluation", ref valueCdEvaluation);

                    if (!string.IsNullOrEmpty(valueObjEvaluation))
                    {
                        classEvaluation objEvaluation = JsonConvert.DeserializeObject <classEvaluation>(valueObjEvaluation);

                        if (objEvaluation.insertAlter())
                        {
                            redirect = true;

                            if (objEvaluation.id == 0)
                            {
                                TempData["alterSaveEvaluationOK"] = "Avaliacao salva com sucesso!";
                            }
                            else
                            {
                                TempData["alterSaveEvaluationOK"] = "Avaliacao alterada com sucesso!";
                            }
                        }
                        else
                        {
                            objErro = objEvaluation.objErro;
                        }
                    }
                    else if (string.IsNullOrEmpty(valueObjEvaluation) && !string.IsNullOrEmpty(valueCdEvaluation))
                    {
                        classEvaluation objEvaluation     = new classEvaluation();
                        classEvaluation objEvaluationTemp = new classEvaluation();

                        if (objEvaluation.getById(ref objEvaluationTemp, Convert.ToInt32(valueCdEvaluation)))
                        {
                            fillforms(objEvaluationTemp);
                        }
                        else
                        {
                            objErro = objEvaluation.objErro;
                        }
                    }
                }
                else
                {
                    objErro = objCustomer.objErro;
                }
            }
            else
            {
                objErro = objTypes.objErro;
            }
        }