/// <summary> /// Update an existing Geocache in the DB /// </summary> /// <param name="id"></param> /// <param name="request"></param> /// <returns>GeocacheEntity</returns> public GeocacheEntity Save(uint id, GeocacheRequest request) { var geocache = _context.Geocache.First(x => x.Id == id); geocache.Name = request.Name; geocache.Latitude = request.Latitude; geocache.Longitude = request.Longitude; _context.SaveChanges(); return(geocache); }
public void UpdateGeocacheEntity() { GeocacheRequest request = new GeocacheRequest { Name = "Update Test", Latitude = 0, Longitude = 0 }; var geocache = geocacheController.Put(1, request); Assert.True(geocache.Name == "Update Test"); }
public void AddGeocacheEntity() { GeocacheRequest request = new GeocacheRequest { Name = "New Geocache Test", Latitude = 0, Longitude = 0 }; var geocache = geocacheController.Post(request); Assert.True(geocache.Id > 0); }
/// <summary> /// Create and add a new Geocache to the DB /// </summary> /// <param name="request"></param> /// <returns>GeocacheEntity</returns> public GeocacheEntity Save(GeocacheRequest request) { var geocache = new GeocacheEntity { Name = request.Name, Latitude = request.Latitude, Longitude = request.Longitude }; _context.Geocache.Add(geocache); _context.SaveChanges(); return(geocache); }
public GeocacheEntity Put(uint id, GeocacheRequest req) { return(client.Save(id, req)); }
public GeocacheEntity Post([FromBody] GeocacheRequest req) { return(client.Save(req)); }