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)); }
public ActionResult SelectDistrictData() { var districts = new List <DistrictModel>(); using (var db = new LeafletContext()) { districts = db.Districts.Select(i => new DistrictModel() { Id = i.Id, Name = i.Name, Coordinates = i.Coordinates }).ToList(); } return(Json(districts, JsonRequestBehavior.AllowGet)); }
public ActionResult SelectDoorData() { var doors = new List <DoorModel>(); using (var db = new LeafletContext()) { doors = db.Doors.Select(i => new DoorModel() { Id = i.Id, DoorNo = i.DoorNo, Coordinate = i.Coordinate, DistrictId = i.DistrictId, DistrictName = i.District.Name }).ToList(); } return(Json(doors, JsonRequestBehavior.AllowGet)); }
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)); }
public JsonResult SelectData() { var data = new LeafletModel(); using (var db = new LeafletContext()) { data.Doors = db.Doors.Select(i => new DoorModel() { Id = i.Id, DoorNo = i.DoorNo, Coordinate = i.Coordinate, DistrictId = i.DistrictId }).ToList(); data.Districts = db.Districts.Select(i => new DistrictModel() { Id = i.Id, Name = i.Name, Coordinates = i.Coordinates }).ToList(); } return(Json(data, JsonRequestBehavior.AllowGet)); }