コード例 #1
0
        public IHttpActionResult PutTripLocation(long id, TripLocation tripLocation)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            if (id != tripLocation.Id)
            {
                return BadRequest();
            }

            db.Entry(tripLocation).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!TripLocationExists(id))
                {
                    return NotFound();
                }
                else
                {
                    throw;
                }
            }

            return StatusCode(HttpStatusCode.NoContent);
        }
コード例 #2
0
ファイル: DataSeed.cs プロジェクト: adriansimmo/WheresMyDaddy
 public void Seed()
 {
     // TripLocation data
     TripLocation tl = new TripLocation();
     //tl.Id = 1;
     tl.Longitude = System.Convert.ToDecimal(-36.9355829);
     tl.Latitude = System.Convert.ToDecimal(174.6426804);
     tl.InsertDate = System.DateTime.Now;
 }
コード例 #3
0
        private TripLocation Trip()
        {
            TripLocation tl = new TripLocation();
            tl.Longitude = System.Convert.ToDecimal(-36.9355829);
            tl.Latitude = System.Convert.ToDecimal(174.6426804);
            tl.InsertDate = System.DateTime.Now;

            return tl;
        }
コード例 #4
0
        public IHttpActionResult PostTripLocation(TripLocation tripLocation)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            db.TripLocations.Add(tripLocation);
            db.SaveChanges();

            return CreatedAtRoute("DefaultApi", new { id = tripLocation.Id }, tripLocation);
        }
コード例 #5
0
        private static async Task RunAsync()
        {
            //TODO: sort this!
            TripLocation tl = new TripLocation();
            tl.Longitude = System.Convert.ToDecimal(-36.9355829);
            tl.Latitude = System.Convert.ToDecimal(174.6426804);
            tl.InsertDate = System.DateTime.Now;

            using (var client = new HttpClient())
            {
                client.BaseAddress = new Uri("http://localhost");
                HttpResponseMessage response = await client.PostAsJsonAsync("wheresmydaddy/api/TripLocations", tl);
            }
        }