public ActionResult <List <CenterNameVM> > CentersToPm()
        {
            var user = GetUser();

            if (!user.Permissions.Contains(Permission.WriteEquipmentPM))
            {
                return(Unauthorized());
            }
            var list = new List <CenterNameVM>();

            foreach (var cityId in user.Cities)
            {
                var city = db.FindById <City>(cityId);
                list.AddRange(db.Find <CommCenterX>(c => c.City == cityId && c.EquipmentsPmEnabled)
                              .SortByDescending(c => c.ImportanceLevel).ThenBy(c => c.Name)
                              .ToEnumerable()
                              .Select(c => new CenterNameVM {
                    CityName = city.Name, Name = c.Name, Id = c.Id, PMPeriodDays = c.PMPeriodDays
                }));
            }
            foreach (var item in list)
            {
                item.ElapsedDaysOfLastPm = CommCenterController.GetDaysLastPM(db, item.Id);
            }
            return(list);
        }
        public ActionResult <EquipmentsPM> New(string centerId)
        {
            var center = CommCenterController.GetItem(db, centerId);
            var user   = GetUser();
            var pm     = new EquipmentsPM {
                CenterId = centerId
            };

            if (user.AllowedEquipmentTypes.Contains(EquipmentType.Diesel))
            {
                foreach (var eq in center.Diesels)
                {
                    pm.DieselsPM.Add(new DieselPM(eq));
                }
            }
            if (user.AllowedEquipmentTypes.Contains(EquipmentType.Rectifier))
            {
                foreach (var eq in center.RectifierAndBatteries)
                {
                    pm.RectifiersPM.Add(new RectifierPM(eq));
                }
            }
            if (user.AllowedEquipmentTypes.Contains(EquipmentType.Battery))
            {
                foreach (var eq in center.RectifierAndBatteries)
                {
                    pm.BatteriesPM.Add(new BatteryPM(eq));
                }
            }
            if (user.AllowedEquipmentTypes.Contains(EquipmentType.Compressor))
            {
                foreach (var eq in center.Compressors)
                {
                    pm.CompressorsPM.Add(new CompressorPM(eq));
                }
            }
            if (user.AllowedEquipmentTypes.Contains(EquipmentType.GasCable))
            {
                foreach (var eq in center.GasCables)
                {
                    pm.GasCablesPM.Add(new GasCablePM(eq));
                }
            }
            return(pm);
        }