private List<EquipmentAndPointsViewModel> _retrievePointsStatus(Company company, string type, string roleType)
        {
            if (company == null)
            {
                return new List<EquipmentAndPointsViewModel>();
            }

            // TO DO
            // Let's assume to build a table with a single point per row
            var equipList = _buildingService.GetEquipmentByCompany(type, company);
            var viewModelMap = new Dictionary<string, EquipmentAndPointsViewModel>();

            foreach (var item in equipList)
            {
                PointRole pt = item.PointRoles.Items.FirstOrDefault(r => r.Type.Id == roleType);
                // For now let's filter out equipment without the requested pointrole.
                // Not sure if we need them or not
                if (pt != null)
                {
                    var model = new EquipmentAndPointsViewModel
                    {
                        EquipmentName = item.Name,
                        EquipmentId = item.Id,
                        EquipmentType = item.Type.Id,
                    };
                    var list = new List<PointViewModel>();
                    var m = new PointViewModel() { PointRole = pt.Type.Id, PointId = pt.Point.Id };
                    list.Add(m);
                    model.PointsStatus = list;
                    viewModelMap.Add(model.PointsStatus.First().PointId, model);
                }
            }

            if (viewModelMap.Count == 0)
            {
                return new List<EquipmentAndPointsViewModel>();
            }

            var pointsInfo = _buildingService.GetPointsSummary(viewModelMap.Keys, company);
            foreach (var item in pointsInfo)
            {
                if (viewModelMap.ContainsKey(item.Id) && viewModelMap[item.Id].PointsStatus.Any())
                {
                    viewModelMap[item.Id].PointsStatus.First().UoM = (item.Units == null) ? item.States.Id : item.Units.Id;
                    // At this point GetPointsSummary does not return the nested Newest field
                    // To be improved
                    if (item.SampleSummary.Newest != null)
                    {
                        viewModelMap[item.Id].PointsStatus.First().LastValue = string.Format("{0:0.##}", item.SampleSummary.Newest.Value);
                        viewModelMap[item.Id].PointsStatus.First().TimeStampLastValue = item.SampleSummary.Newest.Timestamp;
                    }
                }
            }

            return viewModelMap.Values.ToList();
        }
        private IEnumerable<EquipmentAndPointsViewModel> _retrievePointsStatus(Company company, string type)
        {
            var eqListVM = new List<EquipmentAndPointsViewModel>();
            if (company == null)
            {
                return eqListVM;
            }

            var equipList = _buildingService.GetEquipmentByCompany(type, company).ToList();
            var equip2PointsMap = new Dictionary<string,Dictionary<string, PointViewModel>>();

            foreach (var item in equipList)
            {
                var pointsMap = new Dictionary<string, PointViewModel>();
                // Does the equipment API support paging ??
                foreach (var ptr in item.PointRoles.Items)
                {
                    var model = new PointViewModel
                    {
                        PointRole = ptr.Type.Id,
                        PointId = ptr.Point.Id
                    };
                    pointsMap.Add(ptr.Point.Id, model);
                }
                equip2PointsMap.Add(item.Id, pointsMap);
            }

            if (equip2PointsMap.Count == 0)
            {
                return eqListVM;
            }
            // Get all point ids across equipment
            var pointIdsList = new List<string>();
            foreach (var equip in equip2PointsMap)
                pointIdsList.AddRange(equip.Value.Keys.ToList());

            var pointsInfo = _buildingService.GetPointsSummary(pointIdsList, company).ToList();
            // ?? Linq here ??
            foreach (var equip in equip2PointsMap)
            {
                foreach (var item in pointsInfo)
                {
                    var pointStatus = equip.Value.Select(pts => pts.Key == item.Id);
                    if (equip.Value.ContainsKey(item.Id))
                    {
                        equip.Value[item.Id].UoM = item.Units.Id ?? "-";
                        // At this point GetPointsSummary does not return the nested Newest field
                        // To be improved
                        if (item.SampleSummary.Newest != null)
                        {
                            equip.Value[item.Id].LastValue = string.Format("{0:0.##}", item.SampleSummary.Newest.Value);
                            equip.Value[item.Id].TimeStampLastValue = item.SampleSummary.Newest.Timestamp;
                        }
                    }
                }
            }
            // build the final viewmodel
            foreach (var item in equipList)
            {
                // Skip equipment without points
                if (item.PointRoles.Items.Any())
                {
                    var eq = new EquipmentAndPointsViewModel()
                    {
                        EquipmentName = item.Name,
                        EquipmentId = item.Id,
                        EquipmentType = item.Name
                    };
                    if (equip2PointsMap.ContainsKey(item.Id))
                        eq.PointsStatus = equip2PointsMap[item.Id].Values.ToList();
                    eqListVM.Add(eq);
                }
            }
            return eqListVM;
        }