public IHttpActionResult PostDropPin(DropPin droppin) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.DropPins.Add(droppin); try { db.SaveChanges(); } catch (DbUpdateException) { if (DropPinExists(droppin.Id)) { return(Conflict()); } else { throw; } } return(CreatedAtRoute("DefaultApi", new { id = droppin.Id }, droppin)); }
// PUT api/DropPin/5 public IHttpActionResult PutDropPin(long id, DropPin droppin) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != droppin.Id) { return(BadRequest()); } db.Entry(droppin).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!DropPinExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
private void UpdatePinTitle(DropPin dropPin) { var title = dropPin.Pin.Label ?? " "; var mapIcon = dropPin.PlatformMarker as MapIcon; if (mapIcon != null) { mapIcon.Title = string.IsNullOrWhiteSpace(dropPin.Pin.Address) ? title : $"{title}\n{dropPin.Pin.Address}"; } }
public IHttpActionResult GetDropPin(long id) { DropPin droppin = db.DropPins.Find(id); if (droppin == null) { return(NotFound()); } return(Ok(droppin)); }
public IHttpActionResult DeleteDropPin(long id) { DropPin droppin = db.DropPins.Find(id); if (droppin == null) { return(NotFound()); } db.DropPins.Remove(droppin); db.SaveChanges(); return(Ok(droppin)); }