public async Task <List <CountClass> > GetCentersCountList([FromUri] int[] centerID)
        {
            List <CountClass> list = new List <CountClass>();

            foreach (int i in centerID)
            {
                CountClass obj = new CountClass();
                obj = await GetCountList(i);

                list.Add(obj);
            }
            return(list);
        }
        public async Task <CountClass> GetCountList()
        {
            GlobalConfiguration.Configuration.Formatters.JsonFormatter.SerializerSettings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore;
            CountClass clObj = new CountClass();

            var date   = System.DateTime.Now.AddDays(-600);
            var result = date.Date;

            // var total="";
            //DateTime result ="";
            // var lowCount = (from p in db.Persons
            //                 join l in db.Locations on p.Id equals l.PersonId
            //                 where p.CenterId == 4 && p.Active == true && l.BatteryPercentage <= 10
            //                 select new
            //                 {
            //                     l.ServerDate,
            //                     l.PersonId,
            //                     l.BatteryPercentage
            //                 }).ToList();
            //foreach(var s in lowCount)
            // {
            //   var  final = s.ServerDate<= result;
            //     if (final != false)
            //     {


            //         total += final;
            //     }
            // }



            //l.ServerDate.Date == System.DateTime.Now.Date
            // DateTime.Compare(l.ServerDate,System.DateTime.Now)==0


            clObj.lowCount    = (await db.Locations.Where(tbl => DbFunctions.TruncateTime(tbl.ServerDate) == DbFunctions.TruncateTime(System.DateTime.Now) && tbl.BatteryPercentage <= 10).Distinct().LongCountAsync());
            clObj.mediumCount = (await db.Locations.Where(tbl => DbFunctions.TruncateTime(tbl.ServerDate) == DbFunctions.TruncateTime(System.DateTime.Now) && tbl.BatteryPercentage <= 35 && tbl.BatteryPercentage >= 11).LongCountAsync());
            clObj.NormalCount = (await db.Locations.Where(tbl => DbFunctions.TruncateTime(tbl.ServerDate) == DbFunctions.TruncateTime(System.DateTime.Now) && tbl.BatteryPercentage >= 36).LongCountAsync());
            return(clObj);
        }
        public async Task <CountClass> GetCountList(int centerID)
        {
            GlobalConfiguration.Configuration.Formatters.JsonFormatter.SerializerSettings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore;
            CountClass clObj   = new CountClass();
            var        lcounts = await(from persons in db.Persons
                                       join Locations in db.Locations on persons.Id equals Locations.PersonId
                                       where persons.CenterId == centerID && Locations.BatteryPercentage <= 10 && DbFunctions.TruncateTime(Locations.ServerDate) == DbFunctions.TruncateTime(System.DateTime.Now)
                                       select new
            {
                ID = Locations.PersonId
            }).ToListAsync();

            clObj.lowCount = lcounts.Distinct().Count();;
            var mcounts = await(from persons in db.Persons
                                join Locations in db.Locations on persons.Id equals Locations.PersonId
                                where persons.CenterId == centerID && Locations.BatteryPercentage > 10 && Locations.BatteryPercentage <= 35 && DbFunctions.TruncateTime(Locations.ServerDate) == DbFunctions.TruncateTime(System.DateTime.Now)

                                select new
            {
                ID = Locations.PersonId
            }).ToListAsync();

            clObj.mediumCount = mcounts.Distinct().Count();
            var ncounts = await(from persons in db.Persons
                                join Locations in db.Locations on persons.Id equals Locations.PersonId
                                where persons.CenterId == centerID && Locations.BatteryPercentage > 35 && DbFunctions.TruncateTime(Locations.ServerDate) == DbFunctions.TruncateTime(System.DateTime.Now)

                                select new
            {
                ID = Locations.PersonId
            }).ToListAsync();

            clObj.NormalCount = ncounts.Distinct().Count();

            //clObj.lowCount = (await db.Locations.Where(tbl => tbl.BatteryPercentage <= 10 && DbFunctions.TruncateTime(tbl.ServerDate) == DbFunctions.TruncateTime(System.DateTime.Now)).LongCountAsync());
            //clObj.mediumCount = (await db.Locations.Where(tbl => tbl.BatteryPercentage <= 35 && tbl.BatteryPercentage >= 11 && DbFunctions.TruncateTime(tbl.ServerDate) == DbFunctions.TruncateTime(System.DateTime.Now)).LongCountAsync());
            //clObj.NormalCount = (await db.Locations.Where(tbl => tbl.BatteryPercentage >= 36 && DbFunctions.TruncateTime(tbl.ServerDate) == DbFunctions.TruncateTime(System.DateTime.Now)).LongCountAsync());
            return(clObj);
        }