public async Task <ActionResult <PublicApi.v1.DTO.Location> > PostLocation(PublicApi.v1.DTO.Location location)
        {
            await _bll.Location.AddAsync(PublicApi.v1.Mappers.LocationMapper.MapFromExternal(location));

            await _bll.SaveChangesAsync();

            return(CreatedAtAction("GetLocation", new { id = location.Id }, location));
        }
        public async Task <IActionResult> PutLocation(int id, PublicApi.v1.DTO.Location location)
        {
            if (id != location.Id)
            {
                return(BadRequest());
            }

            _bll.Location.Update(PublicApi.v1.Mappers.LocationMapper.MapFromExternal(location));
            await _bll.SaveChangesAsync();

            return(NoContent());
        }
示例#3
0
        public async Task <ActionResult <Location> > PostLocation(PublicApi.v1.DTO.Location administrativeUnit)
        {
            administrativeUnit.AppUserId = User.GetUserId();

            administrativeUnit = PublicApi.v1.Mappers.LocationMapper.MapFromBLL(
                _bll.Locations.Add(PublicApi.v1.Mappers.LocationMapper.MapFromExternal(administrativeUnit)));
            await _bll.SaveChangesAsync();

            administrativeUnit = PublicApi.v1.Mappers.LocationMapper.MapFromBLL(
                _bll.Locations.GetUpdatesAfterUOWSaveChanges(PublicApi.v1.Mappers.LocationMapper.MapFromExternal(administrativeUnit)));

            // get the new id into the object

            return(CreatedAtAction("GetLocation", new { id = administrativeUnit.Id }, administrativeUnit));
        }
示例#4
0
        public async Task <IActionResult> PutLocation(int id, PublicApi.v1.DTO.Location administrativeUnit)
        {
            if (id != administrativeUnit.Id)
            {
                return(BadRequest());
            }

            // check for the ownership - is this Person record really belonging to logged in user.
            if (!await _bll.Locations.BelongsToUserAsync(id, User.GetUserId()))
            {
                return(NotFound());
            }

            administrativeUnit.AppUserId = User.GetUserId();

            _bll.Locations.Update(PublicApi.v1.Mappers.LocationMapper.MapFromExternal(administrativeUnit));
            await _bll.SaveChangesAsync();


            return(NoContent());
        }