public bool SaveSpot(SponsorSpot spot) { var result = Spots.Save(spot, new MongoInsertOptions { WriteConcern = WriteConcern.Acknowledged }); return result.Ok; }
/// <summary> /// Inserts a new spot into the db. /// </summary> /// <param name="spot">The spot to add.</param> /// <returns>true if the spot is valid and successfully added.</returns> public bool Insert(SponsorSpot spot) { spot.SpotID = ObjectId.GenerateNewId(); var result = Spots.Insert(spot, WriteConcern.Acknowledged); return result.Ok; }
public JsonResult UploadSponsors(ObjectId id, HttpPostedFileBase shapeFile) { bool success = true; try { dynamic file = LoadFile(shapeFile); if (file != null) { // remove old parcels Context.SponsorSpots.DeleteByPhaseID(id); // add the new parcels List<SponsorSpot> spots = new List<SponsorSpot>(); foreach (var feature in file.features) { SponsorSpot spot = new SponsorSpot() { PhaseID = id }; foreach (var coord in feature.geometry.coordinates[0]) { spot.SpotShape.Add(new Coordinate { Latitude = coord[0], Longitude = coord[1] }); } spots.Add(spot); } success = Context.SponsorSpots.InsertBatch(spots); } } catch { success = false; } return Json(new { success = success }); }