public IActionResult TariffManager() { var tariffs = _tariffService.GetAll(); var tariffsOptions = _tariffOptionDescriptionService.GetAll(); var model = new TariffManagerViewModel { Tariffs = tariffs.Select(x => new EditTariffViewModel { Id = x.Id, Name = x.Name, Price = x.Price, DaysActive = x.DaysActive, Description = x.Description }), TariffOptionDescriptions = tariffsOptions.Select(x => new TariffOptionDescriptionViewModel { Id = x.Id, Name = x.Name, Description = x.Description }), }; return(View(model)); }
public EditTariffViewModel GetById(int id) { var tariff = _context.Tariffs.FirstOrDefault(x => x.Id == id); if (tariff is null) { return(null); } return(new EditTariffViewModel { Id = tariff.Id, Name = tariff.Name, Price = tariff.Price, DaysActive = tariff.DaysActive, Description = tariff.Description, AllOptions = _tariffOptionDescriptionService.GetAll(), AssignedOptions = _tariffOptionsService.GetAllOptionsAssignedToATariffById(id) }); }