Пример #1
0
        public chartViewModel GetContactBylabel(int adminId)
        {
            chartViewModel      _item   = new chartViewModel();
            List <chartItem>    item    = new List <chartItem>();
            Global              _global = new Database.Global();
            CRMClassDataContext _idc    = new Database.CRMClassDataContext(_global.con);

            try
            {
                var query = (from post in _idc.tblcontacts.Where(a => a.AdminId == adminId && a.IsActive == true)
                             join t in _idc.tbllabels on post.LabelId equals t.Id
                             select new { Post = post, t = t }).GroupBy(a => a.t.LableName).
                            Select(o => new { name = o.Key, Count = o.Count() }).ToList();
                foreach (var items in query)
                {
                    chartItem chrt = new chartItem();
                    chrt.name  = items.name;
                    chrt.value = items.Count;
                    item.Add(chrt);
                }
                _item.data = item;
            }
            catch (Exception ex)
            {
            }
            finally
            {
                _idc.Dispose();
            }
            return(_item);
        }
Пример #2
0
        public chartViewModel GetJobByStatus(int adminId)
        {
            chartViewModel      _item   = new chartViewModel();
            List <chartItem>    item    = new List <chartItem>();
            Global              _global = new Database.Global();
            CRMClassDataContext _idc    = new Database.CRMClassDataContext(_global.con);

            try
            {
                var       pending   = _idc.tblJobMasters.Where(a => a.OpenBy == adminId.ToString() && a.IsActive == true && a.StatusId == 2).Count();
                var       NewJobs   = _idc.tblJobMasters.Where(a => a.OpenBy == adminId.ToString() && a.IsActive == true && a.StatusId == 1).Count();
                var       problem   = _idc.tblJobMasters.Where(a => a.OpenBy == adminId.ToString() && a.IsActive == true && a.StatusId == 3).Count();
                var       Completed = _idc.tblJobMasters.Where(a => a.OpenBy == adminId.ToString() && a.IsActive == true && a.StatusId == 4).Count();
                chartItem i         = new chartItem();
                i.name  = "Pending";
                i.value = pending;
                item.Add(i);
                chartItem i1 = new chartItem();
                i1.name  = "New";
                i1.value = NewJobs;
                chartItem i2 = new chartItem();
                i2.name  = "Problem";
                i2.value = problem;
                chartItem i3 = new chartItem();
                i3.name  = "Completed";
                i3.value = Completed;
                item.Add(i1);
                item.Add(i2);
                item.Add(i3);
                _item.data = item;
            }
            catch (Exception ex)
            {
            }
            finally
            {
                _idc.Dispose();
            }
            return(_item);
        }