public ActionResult DetalheRemuneracao(int id) { var remuneracaoRegras = new RemuneracaoServidorRegras { Servico = new RemuneracaoServidorDados() }; //var model = // AutoMapperConfig.Mapper.Map<RemuneracaoViewModel>( // remuneracaoRegras.ObterPorId(id)); var item = remuneracaoRegras.ObterPorId(id); var model = new RemuneracaoViewModel() { Id = item.Id, Nome = item.Nome, Cpf = item.Cpf, TipoVinculo = item.TipoVinculo, Cargo = item.Cargo, RemuneracaoMensal = item.RemuneracaoMensal, RemuneracaoEventual = item.RemuneracaoEventual, TotalDescontos = item.TotalDescontos, LimiteRemuneratorio = item.LimiteRemuneratorio, TotalLiquido = item.TotalLiquido, Competencia = item.Competencia }; if (model == null) { return(RedirectToAction("consulta-remuneracao")); } TempData["Cpf"] = model.Cpf; var listaCompetencia = new List <SelectListItem>(); var modelLista = remuneracaoRegras.ListaCompetenciaCpf(model.Cpf); var comp = new DateTime(model.Competencia.Year, model.Competencia.Month, model.Competencia.Day); listaCompetencia = modelLista.Select(c => new SelectListItem { Value = c.ToString("d"), Text = c.ToString("MMMM/yyyy"), Selected = c.Equals(comp) }).ToList(); var sb = new StringBuilder(); sb.AppendFormat("<h3>Competencia: {0:d}</h3>", comp); foreach (var x in listaCompetencia) { sb.AppendFormat("<h4>{0} - {1}</h5>", x.Value, x.Selected); } ViewBag.Statues = sb.ToString(); ViewBag.ListaCompetencia = listaCompetencia; return(View(model)); }
public ActionResult _DetalheMensalRemuneracao([Bind(Include = "competenciaData")] DateTime?competenciaData) { var cpf = TempData["Cpf"].ToString(); if (string.IsNullOrEmpty(cpf) || !competenciaData.HasValue || competenciaData.Value <= new DateTime(1, 1, 1)) { return(RedirectToAction("consulta-remuneracao")); } var remuneracaoRegras = new RemuneracaoServidorRegras { Servico = new RemuneracaoServidorDados() }; var dbModel = remuneracaoRegras.ObterPorCpfCompetencia(cpf, competenciaData.Value); //var model = AutoMapperConfig.Mapper.Map<RemuneracaoViewModel>(dbModel); var item = dbModel; var model = new RemuneracaoViewModel() { Id = item.Id, Nome = item.Nome, Cpf = item.Cpf, TipoVinculo = item.TipoVinculo, Cargo = item.Cargo, RemuneracaoMensal = item.RemuneracaoMensal, RemuneracaoEventual = item.RemuneracaoEventual, TotalDescontos = item.TotalDescontos, LimiteRemuneratorio = item.LimiteRemuneratorio, TotalLiquido = item.TotalLiquido, Competencia = item.Competencia }; TempData.Keep("Cpf"); return(PartialView(model)); }
public ActionResult ConsultaPessoa( [Bind(Include = "NomeOrCpf, g-recaptcha-response,GRecaptchaResponse")] RemuneracaoConsultaViewModel model) { if (Global.Dom.Util.ModoSite.Producao == Global.Dom.Util.Itario.AmbienteSite()) { var gRecaptchaResponse = Request["g-recaptcha-response"]; const string googleSecret = "6LdqaRUUAAAAAP899-b-Dayep2eAzF5LSLN_5DTi"; if (!gRecaptchaResponse.Any()) { ModelState.AddModelError("GRecaptchaResponse", @"Valide o reCAPTCHA primeiro."); return(View("ConsultaPessoa", model)); } } if (!ModelState.IsValid) { return(View("ConsultaPessoa", model)); } model.NomeOrCpf = model.NomeOrCpf.RemoveAcentos(); model.NomeOrCpf = Regex.Replace(model.NomeOrCpf, @"[/./-]", "", RegexOptions.IgnoreCase); long possivelCpf; if (long.TryParse(model.NomeOrCpf, out possivelCpf)) { if (!ValidaCPF.IsCpf(model.NomeOrCpf)) { ModelState.AddModelError("GRecaptchaResponse", @"Recaptcha inválido."); ModelState.AddModelError("NomeOrCpf", @"CPF inválido."); return(View("ConsultaPessoa", model)); } } var reply = JsonConvert.SerializeObject(new CaptchaResponseModel { Success = true }); //string.Empty; //try //{ // reply = // new WebClient().DownloadString( // string.Format("https://www.google.com/recaptcha/api/siteverify?secret={0}&response={1}", // googleSecret, gRecaptchaResponse)); //} //catch (WebException webEx) //{ // if (webEx.Status == WebExceptionStatus.NameResolutionFailure) // reply = JsonConvert.SerializeObject(new CaptchaResponseModel { Success = true }); //} //catch (Exception) //{ // reply = JsonConvert.SerializeObject(new CaptchaResponseModel { Success = true }); //} var captchaResponse = JsonConvert.DeserializeObject <CaptchaResponseModel>(reply); if (!captchaResponse.Success) { ModelState.AddModelError("GRecaptchaResponse", @"ReCaptcha inválido ou expirado. Recarregue a página e tente novamente"); return(View("ConsultaPessoa", model)); } var modelList = new RemuneracaoServidorRegras { Servico = new RemuneracaoServidorDados() }.ListaPorNomeCpfCompetencia(model.NomeOrCpf).OrderBy(r => r.Nome); var lista = new List <RemuneracaoViewModel>(); /// AutoMapperConfig.Mapper.Map<IEnumerable<RemuneracaoViewModel>>(modelList); foreach (var item in modelList) { RemuneracaoViewModel data = new RemuneracaoViewModel() { Id = item.Id, Nome = item.Nome, Cpf = item.Cpf, TipoVinculo = item.TipoVinculo, Cargo = item.Cargo, RemuneracaoMensal = item.RemuneracaoMensal, RemuneracaoEventual = item.RemuneracaoEventual, TotalDescontos = item.TotalDescontos, LimiteRemuneratorio = item.LimiteRemuneratorio, TotalLiquido = item.TotalLiquido, Competencia = item.Competencia }; lista.Add(data); } return(View("ResultadoConsultaPessoa", lista)); }