public IActionResult Create() { ViewBag.Classes = _classService.GetAllClasses().Result; ViewBag.Items = _itemService.GetAllItems().Result; ViewBag.Races = _raceService.GetAllRaces().Result; ViewBag.Territories = _territoryService.GetAllTerritories().Result; return(View()); }
public JsonResult GetAllRows() { IEnumerable <TerritoryFlatViewModel> territories; territories = _territoryService.GetAllTerritories().Territories.ConvertToTerritoryFlatViewModels(); DataTableViewModel data = new DataTableViewModel(); data.draw = "1"; data.recordsTotal = territories.ToList().Count.ToString(); data.recordsFiltered = territories.ToList().Count.ToString(); data.data = territories.ToList <object>(); return(Json(data, JsonRequestBehavior.AllowGet)); }
public async Task <IActionResult> Index() { try { IEnumerable <Territory> territories = await _TerritoryService.GetAllTerritories(); var configuration = new MapperConfiguration(cfg => { cfg.CreateMap <Territory, TerritoryViewModel>(); }); IMapper mapper = configuration.CreateMapper(); List <TerritoryViewModel> data = mapper.Map <List <TerritoryViewModel> >(territories); return(View(data)); } catch (Exception) { return(View()); } }