示例#1
0
        public async Task <ActionResult <GeoMessageV1Get> > GetGeoMessage(int id)
        {
            var geoMessage = await _context.GeoMessages.FindAsync(id);

            if (geoMessage == null)
            {
                return(NotFound());
            }

            GeoMessageV1 geoMessageV1Get = new GeoMessageV1Get
            {
                Id        = geoMessage.Id,
                Message   = geoMessage.Body,
                Latitude  = geoMessage.Latitude,
                Longitude = geoMessage.Longitude
            };

            return(Ok(geoMessageV1Get));
        }
示例#2
0
        public async Task <ActionResult <IEnumerable <GeoMessageV1Get> > > GetGeoMessages()
        {
            var geoMessage = await _context.GeoMessages.ToListAsync();

            List <GeoMessageV1Get> geoMessageV1List = new List <GeoMessageV1Get>();

            foreach (var message in geoMessage)
            {
                GeoMessageV1Get geoMessageV1Get = new GeoMessageV1Get
                {
                    Id        = message.Id,
                    Message   = message.Body,
                    Latitude  = message.Latitude,
                    Longitude = message.Longitude
                };
                geoMessageV1List.Add(geoMessageV1Get);
            }

            return(geoMessageV1List);
        }