public async Task <ActionResult> Index(int page = 1) { int pageIndex = page < 1 ? 1 : page; var source = await this.GetHotSpotData(); source = source.AsQueryable().OrderBy(x => x.ID); var model = new HotSpotViewModel { SearchParameter = new HotSpotSearchModel(), PageIndex = pageIndex, Districts = this.GetSelectList(await this.Districts, ""), HotSpotTypes = this.GetSelectList(await this.HotSpotTypes, ""), Companys = this.GetSelectList(await this.Companys, ""), HotSpots = source.ToPagedList(pageIndex, PageSize) }; return(View(model)); }
public async Task <ActionResult> Index(HotSpotViewModel model) { int pageIndex = model.PageIndex < 1 ? 1 : model.PageIndex; var source = await this.GetHotSpotData(); source = source.AsQueryable(); if (!string.IsNullOrWhiteSpace(model.SearchParameter.District)) { source = source.Where(x => x.District == model.SearchParameter.District); } if (!string.IsNullOrWhiteSpace(model.SearchParameter.HotSpotType)) { source = source.Where(x => x.Type == model.SearchParameter.HotSpotType); } if (!string.IsNullOrWhiteSpace(model.SearchParameter.Company)) { source = source.Where(x => x.Company == model.SearchParameter.Company); } source = source.OrderBy(x => x.ID); var result = new HotSpotViewModel { SearchParameter = model.SearchParameter, PageIndex = pageIndex, Districts = this.GetSelectList( await this.Districts, model.SearchParameter.District), HotSpotTypes = this.GetSelectList( await this.HotSpotTypes, model.SearchParameter.HotSpotType), Companys = this.GetSelectList( await this.Companys, model.SearchParameter.Company), HotSpots = source.ToPagedList(pageIndex, PageSize) }; return(View(result)); }
public IActionResult UpdateResult(int id, HotSpotViewModel hotSpotView) { var update = _hotSpotService.Update(id, _mapper.Map <HotSpotViewModel, HotSpotModel>(hotSpotView)); return(RedirectToAction("Edit")); }
public IActionResult CompareNearest(HotSpotViewModel hotspot) { var nearestHotSpot = _hotSpotService.NearestHotSpot(_mapper.Map <HotSpotViewModel, HotSpotModel>(hotspot)); return(View("ComparedHotSpots", nearestHotSpot)); }
public IActionResult Create(HotSpotViewModel hotspot) { var newHotSpo = _hotSpotService.AddHotSpot(_mapper.Map <HotSpotViewModel, HotSpotModel>(hotspot)); return(RedirectToAction("Index")); }