/// <inheritdoc/> public async Task <Position> CreatePositionAsync(UpdatePositionRequest createRequest) { var dbPosition = Mapper.Map <UpdatePositionRequest, DbPosition>(createRequest); _context.Positions.Add(dbPosition); await _context.SaveChangesAsync(); return(Mapper.Map <Position>(dbPosition)); }
/// <inheritdoc/> public async Task <Position> UpdatePositionAsync(int positionId, UpdatePositionRequest updateRequest) { var dbPositions = await _context.Positions.Where(p => p.Id == positionId).ToArrayAsync(); if (dbPositions.Length == 0) { throw new RequestedResourceNotFoundException(); } var dbPosition = dbPositions[0]; Mapper.Map(updateRequest, dbPosition); await _context.SaveChangesAsync(); return(Mapper.Map <Position>(dbPosition)); }