示例#1
0
        /// <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);
        }
示例#2
0
        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");
        }
示例#3
0
        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);
        }
示例#4
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);
        }
示例#5
0
 public GeocacheEntity Put(uint id, GeocacheRequest req)
 {
     return(client.Save(id, req));
 }
示例#6
0
 public GeocacheEntity Post([FromBody] GeocacheRequest req)
 {
     return(client.Save(req));
 }