Пример #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()));
        }
Пример #2
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()));
        }