Ejemplo n.º 1
0
        public async Task <ActionResult <DTOs.Location> > Create([FromBody] DTOs.Location locationDto)
        {
            var location = locationDto.ToLocation();

            var createdLoc = await _locationsRepository.CreateAsync(location);

            return(Created("location", createdLoc.ToLocationDto()));
        }
Ejemplo n.º 2
0
 public static LocPoc.Contracts.Location ToLocation(this DTOs.Location dto)
 {
     return(new LocPoc.Contracts.Location()
     {
         Id = dto.Id,
         Name = dto.Name,
         Description = dto.Description,
         Longitude = dto.Longitude,
         Latitude = dto.Latitude
     });
 }
Ejemplo n.º 3
0
        public async Task <ActionResult <DTOs.Location> > Update(string id, [FromBody] DTOs.Location locationDto)
        {
            locationDto.Id = id;
            var location = locationDto.ToLocation();

            var existingLoc = await _locationsRepository.GetAsync(location.Id);

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

            var updatedLoc = await _locationsRepository.UpdateAsync(location);

            return(Ok(updatedLoc.ToLocationDto()));
        }