// convert the view model meter status to DbModel meter status
        public DbModels.MeterStatus ConvertMeterStatus(Models.MeterStatus mStatus)
        {
            var dbMeterStatus = DbModels.MeterStatus.Inhouse;

            switch (mStatus)
            {
            case Models.MeterStatus.Inhouse:
                dbMeterStatus = DbModels.MeterStatus.Inhouse;
                break;

            case Models.MeterStatus.Install:
                dbMeterStatus = DbModels.MeterStatus.Install;
                break;

            case Models.MeterStatus.Pickup:
                dbMeterStatus = DbModels.MeterStatus.Pickup;
                break;

            case Models.MeterStatus.Return:
                dbMeterStatus = DbModels.MeterStatus.Return;
                break;

            case Models.MeterStatus.Transfer:
                dbMeterStatus = DbModels.MeterStatus.Transfer;
                break;

            default:
                dbMeterStatus = DbModels.MeterStatus.Inhouse;
                break;
            }
            return(dbMeterStatus);
        }
Example #2
0
 // Validating Meter Status
 public bool ValidateMeterStatus(Models.MeterStatus mStatus)
 {
     if (mStatus.Equals(Models.MeterStatus.Inhouse))
     {
         return(true);
     }
     else if (mStatus.Equals(Models.MeterStatus.Install))
     {
         return(true);
     }
     else if (mStatus.Equals(Models.MeterStatus.Pickup))
     {
         return(true);
     }
     else if (mStatus.Equals(Models.MeterStatus.Return))
     {
         return(true);
     }
     else if (mStatus.Equals(Models.MeterStatus.Transfer))
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
        // Update meter status by passing meter ID
        public bool UpdateMeterStatus(string id, Models.MeterStatus meterStatus)
        {
            // convert the meter status to DbModel meter status
            var dbMeterStatus = helper.ConvertMeterStatus(meterStatus);

            var m = _context.Meters.FirstOrDefault(x => x.MIRN == id);

            if (m != null)
            {
                m.MeterStatus = dbMeterStatus;
                _context.SaveChanges();
                return(true);
            }
            else
            {
                return(false);
            }
        }