/// <inheritdoc/>
        public async Task <Location> CreateLocationAsync(UpdateLocationRequest createRequest)
        {
            var dbLocation = Mapper.Map <UpdateLocationRequest, DbLocation>(createRequest);

            _context.Locations.Add(dbLocation);

            await _context.SaveChangesAsync();

            return(Mapper.Map <Location>(dbLocation));
        }
示例#2
0
        /// <inheritdoc/>
        public async Task UpdateLocationAsync(int locationId, UpdateLocationRequest updateRequest)
        {
            var dbLocations = await _context.Locations.Where(l => l.Id == locationId).ToArrayAsync();

            if (dbLocations.Length == 0)
            {
                throw new RequestedResourceNotFoundException();
            }

            var dbLocation = dbLocations[0];

            Mapper.Map(updateRequest, dbLocation);
        }
示例#3
0
        /// <inheritdoc/>
        public async Task CreateLocationAsync(UpdateLocationRequest createRequest)
        {
            var dbLocation = Mapper.Map <UpdateLocationRequest, DbLocation>(createRequest);

            _context.Locations.Add(dbLocation);
        }