// GET: TitikPotongHor public async Task <IActionResult> Index(int?id) { var sesPola = SPola.GetSesi(this); if (id != null) { sesPola.SetPolaId(id); } else { id = sesPola.PolaId; } if (id != 0) { try{ QCekKoordinat cekKoord = new QCekKoordinat(_context, (int)id); //perbaharui tabel titik potong cekKoord.UpdateDariTblTitik(); } catch { } } var rabContext = await _context.TblKoordinat.Where(t => t.TitikX.PolaId == id).OrderBy(t => t.Yid).ThenBy(y => y.Xid).ToListAsync(); bool isAjax = HttpContext.Request.Headers["X-Requested-With"] == "XMLHttpRequest"; if (isAjax) { return(PartialView("RAB/_TblKoordinat", rabContext)); } ViewBag.ListPola = new SelectList(_context.TblPola, "PolaId", "Nama", id); ViewBag.PolaId = id; return(View(rabContext)); }
public IActionResult Index(int? id, int skl = 50, bool dariForm= false) { var sesPola = SPola.GetSesi(this); if (dariForm) sesPola.SetPolaId(id); else id = sesPola.PolaId; decimal skala = (decimal)skl; if (skala < 10) { skala = 100; } var MVGambarGaris = new MVGambarGaris() { Skala = skala / 100, PolaId = id }; if (id != null & id != 0) { //perbaharui tabel koordinat try { QCekKoordinat cekKoord = new QCekKoordinat(_context, (int)id); //perbaharui tabel titik potong cekKoord.UpdateDariTblTitik(); } catch { } var qGaris = new List<OGaris>().AsQueryable(); var qGrsKoor = new List<OKetGarisKoordinat>().AsQueryable(); var qTtkKoor = new List<Koordinat>().AsQueryable(); try { QCekBidangDatar qDatar = new QCekBidangDatar(_context, (int)id); qGaris = qDatar.QryGarisPartial.OrderBy(g => g.Arah); QCekKoordinat qKoor = new QCekKoordinat(_context, (int)id); qGrsKoor = qKoor.GarisKoordinat; qTtkKoor = qKoor.QryTblIniPosUpToDate; MVGambarGaris.TinggiMax = qGrsKoor.Where(g => g.Garis.Arah == ESumbu.Y) .Select(s => s.Garis.Akhir.TitikY.PosAbs).Max() + 300; MVGambarGaris.LebarMax = qGrsKoor.Where(g => g.Garis.Arah == ESumbu.X) .Select(s => s.Garis.Akhir.TitikX.PosAbs).Max() + 300; //buat garis koordinat } catch (Exception) { } MVGambarGaris.LstGarisReal = qGaris.ToList(); MVGambarGaris.LstGrsKoord = qGrsKoor.ToList(); MVGambarGaris.LstKoord = qTtkKoor.ToList(); } ViewBag.Skala = skala / 100; bool isAjax = HttpContext.Request.Headers["X-Requested-With"] == "XMLHttpRequest"; if (isAjax) { return PartialView("RAB/_ViewGambarGaris", MVGambarGaris); } ViewBag.ListSkala = new SelectList(LstSkala, "Nilai", "Nama", skala); ViewBag.ListPola = new SelectList(_context.TblPola, "PolaId", "Nama", id); ViewBag.PolaId = id; // iQueryable tdk bisa menggunkan toListAsync() // jadi untuk sementara pakai toList() aja return View(MVGambarGaris); }