コード例 #1
0
            public async Task <ActionResult <GeoMessageDTO> > PostGeoComment(GeoMessageDTO geoMessageDTO)
            {
                var user = await _userManager.GetUserAsync(this.User);

                var geoMessage = geoMessageDTO.ToModel(user);

                _context.GeoMessages.Add(geoMessage);
                await _context.SaveChangesAsync();

                return(CreatedAtAction("GetGeoComment", new { id = geoMessage.Id }, geoMessageDTO));
            }
コード例 #2
0
            public async Task <ActionResult <GeoMessageDTO> > GetGeoComment(int id)
            {
                var geoTag = await _context.GeoMessages.FirstOrDefaultAsync(g => g.Id == id);

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

                var geoMessageDto = new GeoMessageDTO
                {
                    Message   = geoTag.Body,
                    Latitude  = geoTag.Latitude,
                    Longitude = geoTag.Longitude
                };

                return(Ok(geoMessageDto));
            }