public async Task <ActionResult> MotivoNaoVenda(DateTime datainicial, DateTime datafinal) { var user = (ClaimsIdentity)User.Identity; var response = await Task.FromResult(VisitaViewModel.Get(user.Getcodgrupo(), user.GetEmpresa(), datainicial, datafinal).Where(a => !a.IsVendaRealizada).ToList()); ViewBag.TituloGrafico = $"Motivos não venda {datainicial.Date.ToString("dd/MM/yyyy")} até {datafinal.Date.ToString("dd/MM/yyyy")}"; // var total = response.Count(); var lista = response .GroupBy(a => a.MotivoNaoVenda) .Select(a => new MotivoNaoVendaChartViewModel { MotivoNaoVenda = a.Key, Valor = a.Count(), //(a.Count() / total) * 100, Cliente = new PessoaModel { Endereco = new EnderecoModel { UF = a.First().Cliente.Endereco.UF } } }).ToList(); return(View(lista)); }
public HttpResponseMessage Get(string usuario, string empresa, DataSourceLoadOptions loadOptions) { var response = VisitaViewModel .Get(User.Identity.Getcodgrupo(), empresa, DateTime.Now.Date.Date.FirstDayOfMonth(), DateTime.Now.Date.LastDayOfMonth()) .Where(a => a.Usuario == usuario && a.DataInclusao.Date == DateTime.Now.Date) .ToList().OrderByDescending(a => a.DataVisita); return(Request.CreateResponse(DataSourceLoader.Load(response, loadOptions))); }
private async Task <IEnumerable <VisitaModel> > ListaVendaMesal(VisitaModel visitaModel) { if (visitaModel == null) { return(new List <VisitaModel>()); } var user = (ClaimsIdentity)User.Identity; var response = await Task.FromResult(VisitaViewModel.Get(user.Getcodgrupo(), user.GetEmpresa(), visitaModel.DataVisita, visitaModel.DataVisitaFinal) .Where(a => a.IsVendaRealizada).ToList()); return(response); }
public async Task <HttpResponseMessage> GetAsync(DataSourceLoadOptions loadOptions) { var user = (ClaimsIdentity)User.Identity; var response = await Task.FromResult(VisitaViewModel.Get(user.Getcodgrupo(), user.GetEmpresa(), DateTime.Now.AddMonths(-2), DateTime.Now).Where(a => !a.IsVendaRealizada).ToList()); var lista = response .GroupBy(a => a.MotivoNaoVenda) .Select(a => new MotivoModel { Motivo = a.Key, Qtd = a.Count() }).ToList(); return(Request.CreateResponse(DataSourceLoader.Load(lista, loadOptions))); }
public async Task <ActionResult> Get(DataSourceLoadOptions loadOptions) { var user = (ClaimsIdentity)User.Identity; var response = await Task.FromResult(VisitaViewModel.Get(user.Getcodgrupo(), user.GetEmpresa(), DateTime.Now.AddMonths(-1), DateTime.Now).Where(a => !a.IsVendaRealizada).ToList()); var lista = response .GroupBy(a => a.MotivoNaoVenda) .Select(a => new MotivoModel { Motivo = a.Key, Qtd = a.Count() }).ToList(); var result = DataSourceLoader.Load(lista, loadOptions); var resultJson = JsonConvert.SerializeObject(result); return(Content(resultJson, "application/json")); }