public async Task <ActionResult <GeoMessagesV2> > PostGeoMessages(v1GetDTO geoMessages) { var v2modell = new GeoMessagesV2 { Message = new Message { Body = geoMessages.Message }, longitude = geoMessages.longitude, latitude = geoMessages.latitude }; _context.geoMessagesV2.Add(v2modell); await _context.SaveChangesAsync(); return(CreatedAtAction("GetGeoMessages", new { id = v2modell.Id }, v2modell)); }
public async Task <ActionResult <IEnumerable <v1GetDTO> > > GetgeoMessages() { List <GeoMessagesV2> v2list = await _context.geoMessagesV2.Include(a => a.Message).ToListAsync(); List <v1GetDTO> v1list = new List <v1GetDTO>(); foreach (var item in v2list) { v1GetDTO geoMessages = new v1GetDTO { Message = item.Message.Body, latitude = item.latitude, longitude = item.longitude }; v1list.Add(geoMessages); } return(v1list); }
public async Task <ActionResult <v1GetDTO> > GetGeoMessages(int id) { var geoMessages = await _context.geoMessagesV2.Include(a => a.Message).FirstOrDefaultAsync(b => b.Id == id); if (geoMessages == null) { return(NotFound()); } var v1modell = new v1GetDTO { Message = geoMessages.Message.Body, longitude = geoMessages.longitude, latitude = geoMessages.latitude }; return(v1modell); }