Beispiel #1
0
        public GerStuPosRes SearchStu(string key)
        {
            GerStuPosRes result = new GerStuPosRes();
            var          stu    = db.stu.FirstOrDefault(t => t.number == key || t.name == key);

            if (stu != null)
            {
                result.X = stu.x.Value;
                result.Y = stu.y.Value;
            }
            else
            {
                result.X = -1;
                result.Y = -1;
            }
            return(result);
        }
Beispiel #2
0
        public GerStuPosRes getCityPoint(stu stu)
        {
            GerStuPosRes result = new GerStuPosRes();
            var          pvcode = "";
            var          ctcode = "";
            var          cycode = "";
            var          pvname = "";
            var          ctname = "";
            var          cyname = "";
            var          city   = db.city.SingleOrDefault(t => t.code == stu.pcode);

            if (city != null)
            {
                while (city.level > 1)
                {
                    switch (city.level)
                    {
                    case 3:
                        cycode = city.code;
                        var item = db.city.SingleOrDefault(t => t.code == city.code);
                        if (item != null)
                        {
                            cyname = item.name;
                        }
                        break;

                    case 2:
                        ctcode = city.code;
                        item   = db.city.SingleOrDefault(t => t.code == city.code);
                        if (item != null)
                        {
                            ctname = item.name;
                        }
                        break;

                    default:
                        break;
                    }
                    city = db.city.SingleOrDefault(t => t.code == city.parentcode);
                }
                pvcode = city.code;
                pvname = city.name;
            }
            if (ctcode != "")
            {
                var item = db.city.SingleOrDefault(t => t.code == ctcode);
                if (item != null)
                {
                    result.X = item.X.Value;
                    result.Y = item.Y.Value;
                }
            }
            else
            {
                var item = db.city.SingleOrDefault(t => t.code == pvcode);
                if (item != null)
                {
                    result.X = item.X.Value;
                    result.Y = item.Y.Value;
                }
            }
            return(result);
        }