/// <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)); }
/// <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); }
/// <inheritdoc/> public async Task CreateLocationAsync(UpdateLocationRequest createRequest) { var dbLocation = Mapper.Map <UpdateLocationRequest, DbLocation>(createRequest); _context.Locations.Add(dbLocation); }