public ActionResult ShowAllMeterTypes() { using (var context = new TownUtilityBillSystemEntities()) { var model = new MeterTypeModel(); var meterTypesDB = context.METER_TYPE.ToList(); foreach (var mt in meterTypesDB) { var utilityDB = context.UTILITY.Where(u => u.ID == mt.UTILITY_ID).FirstOrDefault(); var utility = new Utility() { Id = utilityDB.ID, Name = utilityDB.NAME, ImageIconPath = CustomizedMethod.GetUtilityImage(utilityDB.ID) }; model.MeterTypes.Add(new MeterType() { Id = mt.ID, Name = mt.NAME, VarificationPeriod = mt.VARIFICATION_PERIOD_YEARS, Utility = utility }); } var view = View("~/Views/Meter/ShowAllMeterTypes.cshtml", model); return(view); } }
public void CheckGetMeterTypesForUtility_throws_Exception() { string wrongUtilityName = "WrongUtility"; var meterModel = new MeterTypeModel(); meterModel.GetMeterTypesForUtility(wrongUtilityName); }
public ActionResult ShowAllMeterTypes() { var model = new MeterTypeModel(); model.GetAllMeterTypes(); return(View(model)); }
public ActionResult ShowMeterTypesForUtility(string utilityName) { var model = new MeterTypeModel(); model.GetMeterTypesForUtility(utilityName); return(View(model)); }
// GET: Meter public ActionResult ShowMeterTypesForUtility(string utilityName) { using (var context = new TownUtilityBillSystemEntities()) { var model = new MeterTypeModel(); var utilityDB = context.UTILITY.Where(u => u.NAME == utilityName).FirstOrDefault(); var meterTypesDB = context.METER_TYPE.Where(mt => mt.UTILITY_ID == utilityDB.ID).ToList(); model.Utility.Id = utilityDB.ID; model.Utility.Name = utilityDB.NAME; foreach (var mt in meterTypesDB) { model.MeterTypes.Add(new MeterType() { Id = mt.ID, Name = mt.NAME, VarificationPeriod = mt.VARIFICATION_PERIOD_YEARS }); } var view = View("~/Views/Meter/ShowMeterTypesForUtility.cshtml", model); return(view); } }