示例#1
0
        public ActionResult SaveDoorData(DoorModel data)
        {
            using (var db = new LeafletContext())
            {
                db.Doors.Add(new Door()
                {
                    DoorNo = data.DoorNo, Coordinate = data.Coordinate, DistrictId = data.DistrictId
                });
                db.SaveChanges();
            }

            var result = new { Code = 1, Message = "Success" };

            return(Json(result));
        }
示例#2
0
        public ActionResult SaveDistrictData(DistrictModel data)
        {
            var districtList = new List <DistrictModel>();

            using (var db = new LeafletContext())
            {
                db.Districts.Add(new District()
                {
                    Name = data.Name, Coordinates = data.Coordinates
                });
                db.SaveChanges();

                districtList = db.Districts.Select(i => new DistrictModel
                {
                    Id          = i.Id,
                    Name        = i.Name,
                    Coordinates = i.Coordinates
                }).ToList();
            }

            //var result = new { Code = 1, Message = "Success" };

            return(Json(districtList));
        }