// Validating Meter Condition public bool ValidateMeterCondition(Models.MeterCondition mCondition) { if (mCondition.Equals(Models.MeterCondition.Active)) { return(true); } else if (mCondition.Equals(Models.MeterCondition.Faulty)) { return(true); } else if (mCondition.Equals(Models.MeterCondition.Expired)) { return(true); } else { return(false); } }
// Update meter status and meter condition by passing meter ID public bool UpdateMeterStatus(string id, Models.MeterStatus meterStatus, Models.MeterCondition meterCondition) { // convert the meter status to DbModel meter status var dbMeterStatus = helper.ConvertMeterStatus(meterStatus); // Convert the meter condition to DbModel meter condition var dbMeterCondition = helper.ConvertMeterCondition(meterCondition); var m = _context.Meters.FirstOrDefault(x => x.MIRN == id); if (m != null) { m.MeterStatus = dbMeterStatus; m.MeterCondition = dbMeterCondition; _context.SaveChanges(); return(true); } else { return(false); } }
// Convert the meter condition to DbModel meter condition public DbModels.MeterCondition ConvertMeterCondition(Models.MeterCondition mCondition) { var dbMeterCondition = DbModels.MeterCondition.Active; switch (mCondition) { case Models.MeterCondition.Active: dbMeterCondition = DbModels.MeterCondition.Active; break; case Models.MeterCondition.Faulty: dbMeterCondition = DbModels.MeterCondition.Faulty; break; case Models.MeterCondition.Expired: dbMeterCondition = DbModels.MeterCondition.Expired; break; default: dbMeterCondition = DbModels.MeterCondition.Faulty; break; } return(dbMeterCondition); }