Example #1
0
 public void Initiate(System.Reflection.PropertyInfo propertyInfo, object component)
 {
     _component            = component;
     _propertyInfo         = propertyInfo;
     propertyNameText.text = StringFormatUtil.VaraibleNameToString(propertyInfo.Name);
     Initiate();
 }
        public ActionResult Cadastrar(EmpresaViewModel empresa)
        {
            if (StringFormatUtil.SemFormatacao(empresa.CNPJ).Length < 14)
            {
                ModelState.AddModelError("empresa.Invalida", "CNPJ inválido!");
            }
            if (ModelState.IsValid)
            {
                var novaEmpresa = new Empresa
                {
                    NomeFantasia = empresa.NomeFantasia,
                    CNPJ         = StringFormatUtil.SemFormatacao(empresa.CNPJ),
                    UF           = empresa.UF.GetDescription(),
                };

                using (var contexto = new ApplicationContext())
                {
                    contexto.Empresas.Add(novaEmpresa);
                    contexto.SaveChanges();
                }


                TempData["success"] = "Empresa cadastrada com sucesso!";

                return(RedirectToAction("Index", "Home"));
            }

            TempData["warning"] = "Não foi possível cadastrar a empresa!";
            return(View(empresa));
        }
        //---start-------------------------------------------------------------------------------------CLICK EVENTS---//

        private void OnLoginButton(object sender, EventArgs e)
        {
            validationError.Text = "";

            if (!EmailEmpty() && !PasswordEmpty())
            {
                if (EmailValid())
                {
                    var AuthService = DependencyService.Get <IAuthService>();
                    AuthService.SaveCredentials(emailForm.Text.ToLower().Trim(), StringFormatUtil.ToBase64(passwordForm.Text.Trim()));

                    UserExistCheck();
                }
            }
        }
Example #4
0
        public async Task <HostResult> Login(string email, string password)
        {
            JObject @params = new JObject()
            {
                new JProperty("params", new JObject()
                {
                    new JProperty("auth", new JObject()
                    {
                        new JProperty("db", "kamooni"),
                        new JProperty("login", email.ToLower().Trim()),
                        new JProperty("password", StringFormatUtil.ToBase64(password))
                    })
                })
            };

            HostResponse response = await restClient.PostAsync <HostResponse, JObject>(ApiURI.URL_MAIN + ApiURI.URI_SIGN_IN, @params);

            return(response?.Result);
        }
        public ActionResult Cadastrar(FuncionarioViewModel funcionario, int Empresa, int recebeOpcao)
        {
            #region validações
            if (recebeOpcao == 1)
            {
                if (StringFormatUtil.SemFormatacao(funcionario.CpfCnpj).Length < 11)
                {
                    ModelState.AddModelError("funcionario.CpfInvalido", "CPF inválido!");
                }
                if (string.IsNullOrWhiteSpace(funcionario.Rg))
                {
                    ModelState.AddModelError("funcionario.Rg", "Para pessoa fisíca é necessário o RG");
                }
            }
            if (recebeOpcao == 2 && StringFormatUtil.SemFormatacao(funcionario.CpfCnpj).Length < 14)
            {
                ModelState.AddModelError("funcionario.CnpjInvalido", "CNPJ inválido!");
            }

            if (funcionario.DtNascimento.AddYears(18) > DateTime.Now)
            {
                using (var contexto = new ApplicationContext())
                {
                    var empresa = contexto.Empresas.SingleOrDefault(e => e.Id == Empresa);
                    if (empresa.UF.Equals("PR"))
                    {
                        ModelState.AddModelError("funcionario.Menor", "Para empresas do PR não é possível cadastrar um funcionário menor de idade!");
                    }
                }
            }
            #endregion

            if (ModelState.IsValid)
            {
                using (var contexto = new ApplicationContext())
                {
                    var novoFunc = new Funcionario
                    {
                        Nome         = funcionario.Nome,
                        CpfCnpj      = StringFormatUtil.SemFormatacao(funcionario.CpfCnpj),
                        DtCadastro   = DateTime.Now,
                        DtNascimento = funcionario.DtNascimento,
                        Telefone     = funcionario.Telefone,
                        Rg           = funcionario.Rg,
                        Empresa      = contexto.Empresas.SingleOrDefault(e => e.Id == Empresa)
                    };

                    contexto.Funcionarios.Add(novoFunc);
                    contexto.SaveChanges();
                }

                TempData["success"] = "Funcionário cadastrado com sucesso!";

                return(RedirectToAction("Index", "Home"));
            }

            TempData["warning"] = "Não foi possível cadastrar o funcionário!";
            using (var contexto = new ApplicationContext())
            {
                var empresas = contexto.Empresas.ToList();
                ViewBag.Empresa = new SelectList(
                    empresas,
                    "Id",
                    "NomeFantasia");

                return(View(funcionario));
            }
        }
        private async void SubmitReview()
        {
            try
            {
                UserDialogs.Instance.Loading(title: "Submiting Review...").Show();
                var client = new HttpClient()
                {
                    Timeout = TimeSpan.FromSeconds(30)
                };

                //var AuthService = DependencyService.Get<IAuthService>();

                JObject jsonAuth = new JObject
                {
                    { "login", Settings.Email },
                    { "password", StringFormatUtil.ToBase64(Settings.Password) },
                    { "db", ServerAuth.DB }
                };
                string imageBase64 = "";
                if (imagefile != null)
                {
                    byte[] imageBytes = await StorageHelper.LoadImage(imagefile.Path);

                    imageBase64 = Convert.ToBase64String(imageBytes);
                }

                JObject jsonReview = new JObject
                {
                    { "title", Host.Name },
                    { "token", Host.Token },
                    { "text", txtContent.Text?.Trim() ?? "" },
                    { "image", imageBase64 },
                    { "rating", rating.Rating },
                    { "visit_token", "" }
                };

                JObject jsonDataObject = new JObject
                {
                    { "auth", jsonAuth },
                    { "review", jsonReview }
                };

                JObject jsonData = new JObject
                {
                    { "params", jsonDataObject }
                };

                var data     = jsonData.ToString();
                var content  = new StringContent(data, Encoding.UTF8, "application/json");
                var response = await client.PostAsync(ApiURI.URL_MAIN + ApiURI.REVIEW_HOST, content);

                string responseContent = await response.Content.ReadAsStringAsync();

                if (response.StatusCode == HttpStatusCode.OK)
                {
                    ReviewHostResponse successResponse = JsonConvert.DeserializeObject <ReviewHostResponse>(responseContent, App.DefaultSerializerSettings);

                    if (successResponse != null && successResponse.Result != null)
                    {
                        if (successResponse.Result.Success)
                        {
                            ReviewToken = successResponse.Result.ReviewToken;
                            popupShareIns1.IsVisible = true;
                        }
                        else if (!string.IsNullOrWhiteSpace(successResponse.Result.Message))
                        {
                            UserDialogs.Instance.Toast(new ToastConfig(successResponse.Result.Message));
                        }
                    }
                    else
                    {
                        Internal.ServerError();
                    }
                }
                else
                {
                    Internal.ServerError();
                }
            }
            catch (TaskCanceledException e)
            {
                UserDialogs.Instance.Toast(new ToastConfig("Bad Connection Error. Try Again"));
                Debug.WriteLine(e.Message);
            }
            catch (Exception e)
            {
                Internal.ServerError();
                Debug.WriteLine(e.Message);
            }
            finally
            {
                UserDialogs.Instance.Loading().Hide();
            }
        }