public ActionResult EditService(string serviceId) { var service = _servService.GetServiceById(serviceId); var model = new EditServiceViewModel() { Id = service.Id.ToString(), ServiceName = service.ServiceName, Properties = service.Properties, TariffList = new List <EditTariffViewModel>() }; foreach (var tariff in service.TariffList) { model.TariffList.Add(new EditTariffViewModel() { Id = tariff.Id.ToString(), Service_Id = tariff.Service_Id.ToString(), TariffName = tariff.TariffName, TariffProperties = tariff.TariffProperties, Price = tariff.Price, ValidityPeriod = tariff.ValidityPeriod.Days }); } return(View(model)); }
public ActionResult ServiceDetails(string Id) { var service = _servService.GetServiceById(Id); if (service != null) { var model = new ServiceDetailsViewModel { ServiceName = service.ServiceName, Properties = service.Properties, Tariffs = new List <TariffDetailViewModel>() }; foreach (var tariff in service.TariffList) { model.Tariffs.Add(new TariffDetailViewModel() { Id = tariff.Id.ToString(), Price = tariff.Price, TariffName = tariff.TariffName, TariffProperties = tariff.TariffProperties, ValidityPeriod = tariff.ValidityPeriod.Days }); } return(View(model)); } else { return(RedirectToAction("ServiceList")); } }