示例#1
0
        public FileContentResult LeadsByStatusCSV()
        {
            var csv           = new StringBuilder();
            var leadsByStatus = _crmLeadRepository.GetAll().ToList()
                                .GroupBy(l => l.LeadStatus.Name)
                                .Select(x => new
            {
                x.Key,
                Value = x.Count()
            })
                                .ToList();

            var keys = string.Join(",", leadsByStatus.Select(x => x.Key).ToArray());

            csv.AppendLine(keys);
            var values = string.Join(",", leadsByStatus.Select(x => x.Value).ToArray());

            csv.AppendLine(values);
            return(File(new UTF8Encoding().GetBytes(csv.ToString()), "text/csv", "LeadsByStatusCSV.csv"));
        }
示例#2
0
        public JsonResult Index()
        {
            var apiResult = TryExecute(() => _crmLeadRepository.GetAll(), "Leads Fetched sucessfully");

            return(Json(apiResult, JsonRequestBehavior.AllowGet));
        }