コード例 #1
0
        // GET: Tanah
        public ActionResult Index()
        {
            if ((bool)Session["Login"])
            {
                MetaniContext context = new MetaniContext();
                return(View(context.GetAllTanahJoin()));
            }

            return(RedirectToAction("Login", "Admin"));
        }
コード例 #2
0
        // GET: Admin
        public ActionResult Index()
        {
            if ((bool)Session["Login"])
            {
                MetaniContext        context       = new MetaniContext();
                MapTani              mapTani       = new MapTani();
                List <MapList>       hasilTaniList = new List <MapList>();
                List <HasilTaniJoin> hasilTani     = context.GetAllHasilTaniJoin();
                foreach (var item in hasilTani)
                {
                    MapList mapList = new MapList();
                    mapList.nama      = item.jenisTani.NamaJenisTani;
                    mapList.desc      = item.Jumlah.ToString();
                    mapList.latitude  = item.lokasi.Latitude;
                    mapList.longitude = item.lokasi.Longitude;

                    hasilTaniList.Add(mapList);
                }

                mapTani.HasilTani = hasilTaniList;

                List <MapList>   tanahList = new List <MapList>();
                List <TanahJoin> tanah     = context.GetAllTanahJoin();
                foreach (var item in tanah)
                {
                    MapList mapList = new MapList();
                    mapList.nama      = item.JenisTanah.NamaJenisTanah;
                    mapList.desc      = item.LuasTanah.ToString();
                    mapList.latitude  = item.Lokasi.Latitude;
                    mapList.longitude = item.Lokasi.Longitude;

                    tanahList.Add(mapList);
                }

                mapTani.Tanah = tanahList;

                return(View(mapTani));
            }

            return(RedirectToAction("Login"));
        }