Пример #1
0
        private IQueryable <Alert> GetAlerts()
        {
            var locationsScansEmpty =
                new LinqMetaData().Location.WithPermissions()
                .Where(
                    x => x.Devices
                    .Any(y => y.ScansAvailable == 0))
                .ToList()
                .Select(x => new Alert
            {
                Message =
                    String.Format(ControllerRes.Widgets.Alert_ZeroScansRemaining, x.Name),
                Type = AlertType.Error
            });

            var locationsScansLow =
                new LinqMetaData().Location.WithPermissions()
                .Where(
                    x => x.Devices
                    .Any(y => y.ScansAvailable < MIN_SCANS && y.ScansAvailable > 0))
                .ToList()
                .Select(x => new Alert
            {
                Message =
                    String.Format(ControllerRes.Widgets.Alert_ScansRemaining, x.Name, MIN_SCANS),
                Type = AlertType.Warning
            });

            return(locationsScansEmpty.Concat(locationsScansLow).AsQueryable());
        }