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 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)); }