public AggregateViewModel GetAggs <T>(string field, string type)
        {
            string          db       = HttpContext.Current.Session["ConString"].ToString();
            List <SqlWhere> myWheres = new List <SqlWhere>();

            if (HttpContext.Current.Session["GridFilterWheres"] != null)
            {
                myWheres.AddRange((List <SqlWhere>)HttpContext.Current.Session["GridFilterWheres"]);
            }

            if (HttpContext.Current.Session["Searches"] != null)
            {
                List <SqlWhere> searchRequest = (List <SqlWhere>)HttpContext.Current.Session["Searches"];
                searchRequest.First().Andor   = SqlWhereAndOrOptions.SqlWhereAndOr.And;
                searchRequest.First().Group1  = "(";
                searchRequest.Last().Group2   = ")";
                myWheres.AddRange((HttpContext.Current.Session["Searches"] != null) ? (List <SqlWhere>)HttpContext.Current.Session["Searches"] : null);
            }
            AggregateViewModel aggModel = new AggregateViewModel();

            aggModel.Type   = type;
            aggModel.Field  = field;
            aggModel.Result = _coreService.Aggregate <T>(type, field, myWheres, conName: db);
            return(aggModel);
        }
Example #2
0
        // Aggregate
        public ActionResult Aggregate()
        {
            var vm = new AggregateViewModel {
                Title = "Aggregate"
            };

            return(View(vm));
        }
Example #3
0
        public IActionResult Index()
        {
            var streets = _db.Streets.Include(p => p.Houses).ToList();
            var hub     = _db.MeterHubs.FirstOrDefault(p => p.House.id == streets.FirstOrDefault().Houses.FirstOrDefault().id);
            var meters  = _db.Meters.Include(p => p.Flat).Where(p => p.Hub.id == hub.id).ToList();
            var flats   = meters.Select(p => p.Flat).Distinct().OrderBy(p => p.Num).ToList();
            var vm      = new AggregateViewModel
            {
                Streets = streets,
                Hub     = hub,
                Flats   = flats
            };

            return(View(vm));
        }