private void SetBiewBags(CrudCompanyVm model) { ViewBag.Cities = new SelectList(EventController.GetCities(_db), "CityId", "Name", model?.Company?.Address?.CityId); var categories = _db.SubCategories.Where(s => s.CategoryId == null).OrderBy(o => o.Name); ViewBag.Categories = new SelectList(categories, "SubCategoryId", "Name", model?.CategoryId); if (model == null || model.CategoryId == 0) { ViewBag.SubCategories = new SelectList(Enumerable.Empty <SelectListItem>()); } else { var subCategories = _db.SubCategories.Where(s => s.CategoryId != null).OrderBy(o => o.Name); ViewBag.SubCategories = new SelectList(subCategories, "SubCategoryId", "Name", model.SubCategoryId); } }
private void SetBiewBags(CrudHistoricalSightVm model) { ViewBag.Cities = new SelectList(EventController.GetCities(_db), "CityId", "Name", model?.HistoricalSight?.Address?.CityId); }