public async Task <ActionResult> RegisterSmartEnergyMeter(SmartEnergyMeterViewModels model, FormCollection formcollection) { if (ModelState.IsValid) { SmartEnergyMeter.Entities.SmartEnergyMeter smartEM = new Entities.SmartEnergyMeter(); smartEM.CustomerId = model.CustomerId; smartEM.Id = model.Id; smartEM.TariffType = Convert.ToInt32(formcollection["userTypeGrp"]); await client.SmartEnergyMeterInsert(smartEM); return(RedirectToAction("ManageSmartEnergyMeter", "AdminAccount")); } return(View()); }
public async Task <ActionResult> ManageSmartEnergyMeter(string returnUrl) { ViewBag.Message = "Lists the Smart Energy Meters"; List <SmartEnergyMeterViewModels> smartEMList = new List <SmartEnergyMeterViewModels>(); List <SmartEnergyMeter.Entities.SmartEnergyMeter> smartList = await client.SmartEnergyMeterList(); List <Customer> customerList = await client.CustomerGetAll(); foreach (SmartEnergyMeter.Entities.SmartEnergyMeter smart in smartList) { SmartEnergyMeterViewModels temp = new SmartEnergyMeterViewModels(); temp.Id = smart.Id; temp.CustomerName = customerList.Where(x => x.Id == smart.CustomerId).FirstOrDefault() != null?customerList.Where(x => x.Id == smart.CustomerId).FirstOrDefault().Name : ""; temp.TariffType = Enum.GetName(typeof(TariffType), smart.TariffType); smartEMList.Add(temp); } return(View(smartEMList)); }