Esempio n. 1
0
        public async Task <IActionResult> PutGeoPoint(long id, GeoPoint geoPoint)
        {
            if (id != geoPoint.Id)
            {
                return(BadRequest());
            }

            _context.Entry(geoPoint).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!GeoPointExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Esempio n. 2
0
 public async Task <ActionResult> GenerateRamdomGeoPoints(int count)
 {
     for (int i = 0; i < count; i++)
     {
         var randCoord = pointInCircle(Bhopal, 300000);
         _context.GeoPoints.Add(new GeoPoint
         {
             Name      = String.Format("GeoPoint-{0}", random.Next()),
             Latitude  = Math.Round(Convert.ToDecimal(randCoord.Latitude), 6),
             Longitude = Math.Round(Convert.ToDecimal(randCoord.Longitude), 6),
             Address   = "Lorem ipsum dolor sit amet."
         });
         if (i > 0 && i % 100 == 0)
         {
             await _context.SaveChangesAsync();
         }
     }
     return(Ok());
 }