api/equipas

This commit is contained in:
henrydays 2019-03-17 16:12:39 +00:00
parent 435975feda
commit f4ccb246b2
17 changed files with 996 additions and 767 deletions

View File

@ -167,23 +167,34 @@ class App extends Component {
return <Router />;
}
return (
<View style={styles.slide2}>
<Modal isVisible={this.props.UI_loginScannerActive}>
<View style={{ flex: 1, backgroundColor: "white" }}>
<Button
onPress={this.props.closeLoginQRScan}
title={"Fechar scanner"}
>
{" "}
</Button>
<QRCodeScanner
onRead={this.onSuccess}
cameraStyle={styles.cameraContainer}
/>
</View>
</Modal>
<Modal
isVisible={this.props.UI_loginScannerActive}
onBackdropPress={this._toggle}
onBackButtonPress={this._toggle}
animationInTiming={1100}
animationOutTiming={1100}
style={{marginTop:-20}}
>
<QRCodeScanner
onRead={this.onSuccess}
cameraStyle={styles.cameraContainer}
showMarker={true}
/>
<Button
onPress={this.props.closeLoginQRScan}
title={"Fechar Scan"}
color={"#CC1A17"}
></Button>
<Text style={{textAlign:'center', fontSize:12, margin:10,marginBottom:5, color:'white'}}>Sim, o quadrado não está centrado. Era para testar a tua atenção!</Text>
</Modal>
<Modal
isVisible={this.state.modalResetPassword}
onBackdropPress={this._toggle}
@ -191,6 +202,7 @@ class App extends Component {
animationInTiming={1100}
animationOutTiming={1100}
>
<View style={{ backgroundColor: "white" , padding:20,paddingBottom:0, alignItems:'center'}}>
<View>
<Text style={{textAlign:'center',fontSize:23, fontWeight:'bold', color:'#CC1A17', margin:30}}>Reset Password</Text>
@ -213,8 +225,8 @@ class App extends Component {
onPress={this._reset}
title={"Enviar"}
color={"#CC1A17"}
></Button>
<Text style={{textAlign:'center', fontSize:12, margin:10,marginBottom:5}}> Caso tenhas problemas com este processo deves contactar a comissão organizadora atravês do email geral.</Text>
></Button>
<Text style={{textAlign:'center', fontSize:12, margin:10,marginBottom:5}}> Caso tenhas problemas com este processo deves contactar a comissão organizadora atravês do email geral.</Text>
</View>
</View>
@ -233,6 +245,7 @@ class App extends Component {
source={require("./assets/img/logo2.png")}
/>
</View>
{!this.props.loadingLogin &&
<View styles={styles.loginContainer}>
<View style={styles.inputSection}>
<TextInput
@ -277,11 +290,14 @@ class App extends Component {
</TouchableOpacity>
</View>
}
{this.props.alignItems &&
<ActivityIndicator size="large" color="#0000ff" />
}
</View>
}{
this.props.loadingLogin &&
<View style={{margin:100}}>
<ActivityIndicator size="large" color="#CC1A17" />
</View>
}
<View style={styles.buttons}>
<TouchableOpacity style={styles.button}>
<Icon name="logo-facebook" size={40} />

View File

@ -36,9 +36,10 @@ import Profile from "./screens/Profile";
import editCalendar from './screens/editCalendar';
import choosePath from './screens/choosePath';
import calendarDetail from './screens/calendarDetail';
import FebradaDetail from './screens/FebradaDetail';
import resetPassword from './screens/resetPassword';
import eventDetail from './screens/eventDetail'
const navigationOptions = ({navigation}) => ({
headerLeft: <HeaderBackButton onPress={() => navigation.goBack(null)}/>,
headerStyle: {backgroundColor: 'transparent', zIndex: 100 },
@ -144,11 +145,8 @@ const Stack = createStackNavigator({
headerTitle: 'Calendário',
headerRight: (
<View style={{flex: 1, flexDirection: 'row'}}>
<TouchableOpacity style={{marginRight: 20, flex: 1, flexDirection: 'row'}}
onPress={() => navigation.navigate('Edit')}>
<Text>FAQ</Text>
</TouchableOpacity>
<TouchableOpacity style={{marginRight: 20, flex: 1, flexDirection: 'row'}}
onPress={() => navigation.navigate('choosePath')}>
@ -204,8 +202,8 @@ const Stack = createStackNavigator({
calendarDetail: {
screen: calendarDetail,
},
FebradaDetail: {
screen: FebradaDetail,
eventDetail: {
screen: eventDetail,
},
resetPassword:{

View File

@ -27,6 +27,7 @@ const FourthRoute = () => (
export default class Eventos extends React.Component {
state = {
index: 0,
routes: [
@ -41,7 +42,7 @@ export default class Eventos extends React.Component {
renderFebrada = (navigate) => {
return (
<View>
<TouchableOpacity onPress={() => navigate('FebradaDetail')}>
<TouchableOpacity onPress={() => navigate('eventDetail')}>
<View style={styles.cardContainer}>
<Image
style={{

View File

@ -12,9 +12,13 @@ import {
Image,
ImageBackground,
NetInfo,
AppState
AppState,
TextInput,
Keyboard
} from "react-native";
import Modal from "react-native-modal";
import QRCodeScanner from 'react-native-qrcode-scanner';
import { Shadow } from "react-native-shadow";
import Icon from "react-native-vector-icons/Ionicons";
import { RkButton, RkTheme } from "react-native-ui-kitten";
@ -62,7 +66,8 @@ class Home extends Component {
onHold: true,
user: { Name: "" },
userDetails: {},
appState: AppState.currentState
appState: AppState.currentState,
addUser:false
};
}
handleConnectivityChange = () => {
@ -70,19 +75,13 @@ class Home extends Component {
};
componentDidMount() {
// NetInfo.isConnected.addEventListener('connectionChange', this.handleConnectivityChange);
// this.props.hold();
console.log("hold" + this.props.onHold);
//this.props.logoutUser();
//console.log(this.props.token);
this.props.getUserInfo(this.props.token);
//console.log('logged:'+this.props.logged);
//console.log(th2is.props
console.log(this.props.internalToken)
this.props.getUserTeam(this.props.user, "eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJuYW1laWQiOiIxIiwidW5pcXVlX25hbWUiOiJjZW5hIiwicm9sZSI6IkFkbWluIiwibmJmIjoxNTUyODM4NTk5LCJleHAiOjE1NTI5MjQ5OTksImlhdCI6MTU1MjgzODU5OX0.KmzDoneEdlzyaTS3N4pSuRYHkdrpTVjPFXVIB4tMKPh1BK4KtIOfqHJ_H3FsrUEkXKb_tnf38swO5SKQ1wt0cg"
);
this.props.getEvents(this.props.user);
}
componentWillUnmount() {}
@ -101,7 +100,18 @@ class Home extends Component {
this.props.getUserInfo(this.props.token);
this.props.getEvents(this.props.user);
};
onSuccess=e=>{
//fecha o scanner
this.props.addUserTeam({id:this.props.team.id, newQr:e.data}, "eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJuYW1laWQiOiIxIiwidW5pcXVlX25hbWUiOiJjZW5hIiwicm9sZSI6IkFkbWluIiwibmJmIjoxNTUyODM4NTk5LCJleHAiOjE1NTI5MjQ5OTksImlhdCI6MTU1MjgzODU5OX0.KmzDoneEdlzyaTS3N4pSuRYHkdrpTVjPFXVIB4tMKPh1BK4KtIOfqHJ_H3FsrUEkXKb_tnf38swO5SKQ1wt0cg"
)
this.setState({addUser:!this.state.addUser})
}
_toggle=()=>{
this.setState({addUser:!this.state.addUser})
}
render() {
const { navigate } = this.props.navigation;
@ -118,6 +128,31 @@ class Home extends Component {
<PTRView onRefresh={this._update}>
<ScrollView style={{ backgroundColor: "#eeeeee" }}>
<View>
<Modal
isVisible={this.state.addUser}
onBackdropPress={this._toggle}
onBackButtonPress={this._toggle}
animationInTiming={1100}
animationOutTiming={1100}
style={{marginTop:-20}}
>
<QRCodeScanner
onRead={this.onSuccess}
cameraStyle={styles.cameraContainer}
showMarker={true}
/>
<Button
onPress={this._toggle}
title={"Fechar Scan"}
color={"#CC1A17"}
></Button>
<Text style={{textAlign:'center', fontSize:12, margin:10,marginBottom:5, color:'white'}}> Caso tenhas problemas com este processo deves contactar a comissão organizadora atravês do email geral.</Text>
</Modal>
<ImageBackground
opacity={0.9}
source={require("../assets/img/bg_3.jpg")}
@ -150,41 +185,52 @@ class Home extends Component {
O que inclui o meu bilhete?
</Text>
</View>
<View style={{ flex: 1, flexDirection: 'row', flexWrap: 'wrap' }}>
<View style={styles.colBilhete}>
<Text style={styles.titleBilhete}>Acesso </Text>
<FlatList
data={this.props.acesso}
renderItem={({item}) =>
<View style={styles.boxStyle}>
<Text><IconFA name="check" size={18} color={'#CC1A17'}/> {item}</Text>
</View>}
/>
<View
style={{ flex: 1, flexDirection: "row", flexWrap: "wrap" }}
>
<View style={styles.colBilhete}>
<Text style={styles.titleBilhete}>Acesso </Text>
<FlatList
data={this.props.acesso}
renderItem={({ item }) => (
<View style={styles.boxStyle}>
<Text>
<IconFA name="check" size={18} color={"#CC1A17"} />{" "}
{item}
</Text>
</View>
)}
/>
</View>
<View style={styles.colBilhete}>
<Text style={styles.titleBilhete}>Alojamento</Text>
<FlatList
data={this.props.alojamento}
renderItem={({ item }) => (
<View style={styles.boxStyle}>
<Text>
<IconFA name="check" size={18} color={"#CC1A17"} />{" "}
{item}
</Text>
</View>
)}
/>
</View>
<View style={styles.colBilhete}>
<Text style={styles.titleBilhete}>Alimentação</Text>
<FlatList
data={this.props.alimentacao}
renderItem={({ item }) => (
<View style={styles.boxStyle}>
<Text>
<IconFA name="check" size={18} color={"#CC1A17"} />{" "}
{item}
</Text>
</View>
)}
/>
</View>
</View>
<View style={styles.colBilhete}>
<Text style={styles.titleBilhete}>Alojamento</Text>
<FlatList
data={this.props.alojamento}
renderItem={({item}) =>
<View style={styles.boxStyle}>
<Text><IconFA name="check" size={18} color={'#CC1A17'}/> {item}</Text>
</View>}
/>
</View>
<View style={styles.colBilhete}>
<Text style={styles.titleBilhete}>Alimentação</Text>
<FlatList
data={this.props.alimentacao}
renderItem={({item}) =>
<View style={styles.boxStyle}>
<Text><IconFA name="check" size={18} color={'#CC1A17'}/> {item}</Text>
</View>}
/>
</View>
</View>
</View>
<View>
@ -213,7 +259,7 @@ class Home extends Component {
marginBottom: 0
}}
>
Os tones
{this.props.team.nome}
</Text>
<Text
style={{
@ -222,96 +268,51 @@ class Home extends Component {
marginBottom: 5
}}
>
5/6 elementos
{this.props.team.nMembros}/6 elementos
</Text>
</View>
<TouchableOpacity onPress={this._toggle}>
<View
style={{
alignItems: "center",
alignContent: "center",
alignSelf: "center"
alignSelf: "center",
marginTop:7
}}
>
<IconFA name="plus" color={"white"} size={30} />
<Text style={{ color: "white" }}>Adicionar</Text>
</View>
</TouchableOpacity>
</View>
<View>
<View style={{ flex: 1 }}>
<View style={styles.user}>
<View style={styles.userLogo}>
<IconFA name="user" size={40} />
</View>
<View style={styles.userT}>
<Text style={styles.userName}>Henrique Dias</Text>
<Text>AFFJASDXZ</Text>
</View>
<FlatList
data={this.props.team.membros}
renderItem={({ item }) => (
<View>
<View style={styles.user}>
<View style={styles.userLogo}>
<IconFA name="user" size={40} />
</View>
<View style={styles.userT}>
<Text style={styles.userName}>
{item.username}
</Text>
<Text>{item.qRcode}</Text>
</View>
<TouchableOpacity style={styles.userRemove}>
<Text style={{ fontWeight: "bold" }}>rm equipa</Text>
</TouchableOpacity>
</View>
<Divider style={{ backgroundColor: "black" }} />
<View style={styles.user}>
<View style={styles.userLogo}>
<IconFA name="user" size={40} />
</View>
<View style={styles.userT}>
<Text style={styles.userName}>Henrique Dias</Text>
<Text>AFFJASDXZ</Text>
</View>
<TouchableOpacity style={styles.userRemove}>
<IconFA name="times" color={"#CC1A17"} size={30} />
<Text>remover</Text>
</TouchableOpacity>
</View>
<Divider style={{ backgroundColor: "black" }} />
<View style={styles.user}>
<View style={styles.userLogo}>
<IconFA name="user" size={40} />
</View>
<View style={styles.userT}>
<Text style={styles.userName}>Henrique Dias</Text>
<Text>AFFJASDXZ</Text>
</View>
<TouchableOpacity style={styles.userRemove}>
<IconFA name="times" color={"#CC1A17"} size={30} />
<Text>remover</Text>
</TouchableOpacity>
</View>
<Divider style={{ backgroundColor: "black" }} />
<View style={styles.user}>
<View style={styles.userLogo}>
<IconFA name="user" size={40} />
</View>
<View style={styles.userT}>
<Text style={styles.userName}>Henrique Dias</Text>
<Text>AFFJASDXZ</Text>
</View>
<TouchableOpacity style={styles.userRemove}>
<IconFA name="times" color={"#CC1A17"} size={30} />
<Text>remover</Text>
</TouchableOpacity>
</View>
<Divider style={{ backgroundColor: "black" }} />
<View style={styles.user}>
<View style={styles.userLogo}>
<IconFA name="user" size={40} />
</View>
<View style={styles.userT}>
<Text style={styles.userName}>Henrique Dias</Text>
<Text>AFFJASDXZ</Text>
</View>
<TouchableOpacity style={styles.userRemove}>
<IconFA name="times" color={"#CC1A17"} size={30} />
<Text>remover</Text>
</TouchableOpacity>
</View>
<TouchableOpacity style={styles.userRemove}>
<Text style={{ fontWeight: "bold" }}>
remover
</Text>
</TouchableOpacity>
</View>
<Divider style={{ backgroundColor: "black" }} />
</View>
)}
/>
</View>
</View>
</View>
@ -331,24 +332,25 @@ class Home extends Component {
}
const styles = StyleSheet.create({
titleBilhete:{
textAlign:'center',
fontSize:15,
fontWeight:'bold',
marginBottom:10
cameraContainer: {
height: Dimensions.get('window').height,
},
colBilhete:{
width:'33%',
padding:10
titleBilhete: {
textAlign: "center",
fontSize: 15,
fontWeight: "bold",
marginBottom: 10
},
colBilhete: {
width: "33%",
padding: 10
},
boxStyle: {
padding:10,
borderWidth: 1,
padding: 10,
borderWidth: 1,
marginBottom: 5,
borderColor:'#CC1A17'
borderColor: "#CC1A17"
},
userName: {
fontSize: 16,
@ -481,7 +483,9 @@ function mapStateToProps(state, props) {
bilhete: state.apiReducer.bilhete,
alimentacao: state.apiReducer.alimentacao,
alojamento: state.apiReducer.alojamento,
acesso: state.apiReducer.acesso
acesso: state.apiReducer.acesso,
team: state.apiReducer.team,
internalToken: state.apiReducer.internalToken
};
}

View File

@ -20,7 +20,7 @@ import {bindActionCreators} from "redux";
const SCREEN_HEIGHT = Dimensions.get("window").height;
const SCREEN_WIDTH = Dimensions.get("window").width;
class FebradaDetail extends React.Component {
class eventDetail extends React.Component {
static navigationOptions = ({navigation}) => ({
@ -243,4 +243,4 @@ function mapDispatchToProps(dispatch) {
return bindActionCreators(Actions, dispatch);
}
export default connect(mapStateToProps, mapDispatchToProps)(FebradaDetail);
export default connect(mapStateToProps, mapDispatchToProps)(eventDetail);

View File

@ -1,3 +1,11 @@
//MINHA API
export const GET_TEAM='GET_TEAM'
//API BLUETREND

File diff suppressed because it is too large Load Diff

View File

@ -20,7 +20,9 @@ export {checkUser,
removeSession,
changePassword,
resetPassword,
getSessionDetails
getSessionDetails,
getUserTeam,
addUserTeam
} from "./api"

View File

@ -18,7 +18,8 @@ import {
LOADINGLOGIN,
REMOVE_SESSION,
UPDATE_USER,
SESSION_DETAIL
SESSION_DETAIL,
GET_TEAM
} from "../actions/actionTypes"; //Import the actions types constant we defined in our actions
import { REHYDRATE } from "redux-persist";
@ -55,7 +56,10 @@ let apiState = {
alimentacao: [],
acesso: [],
alojamento: [],
sessionDetail:{}
sessionDetail:{},
team:{},
internalToken: "eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJuYW1laWQiOiIxIiwidW5pcXVlX25hbWUiOiJjZW5hIiwicm9sZSI6IkFkbWluIiwibmJmIjoxNTUyODM4NTk5LCJleHAiOjE1NTI5MjQ5OTksImlhdCI6MTU1MjgzODU5OX0.KmzDoneEdlzyaTS3N4pSuRYHkdrpTVjPFXVIB4tMKPh1BK4KtIOfqHJ_H3FsrUEkXKb_tnf38swO5SKQ1wt0cg"
};
const apiReducer = (state = apiState, action) => {
@ -99,7 +103,8 @@ const apiReducer = (state = apiState, action) => {
username: action.payload.apiReducer.userDetails.username,
password: action.payload.apiReducer.userDetails.password
},
token: action.payload.apiReducer.token
token: action.payload.apiReducer.token,
team: action.payload.apiReducer.team,
};
}
@ -143,6 +148,15 @@ const apiReducer = (state = apiState, action) => {
return state;
case GET_TEAM:
state = Object.assign({}, state, {
team: action.team
});
return state;
case CHECK_USER:
state = Object.assign({}, state, {
logged: action.logged,

View File

@ -5,6 +5,7 @@
};
objectVersion = 46;
objects = {
/* Begin PBXBuildFile section */
00C302E51ABCBA2D00DB3ED1 /* libRCTActionSheet.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 00C302AC1ABCB8CE00DB3ED1 /* libRCTActionSheet.a */; };
00C302E71ABCBA2D00DB3ED1 /* libRCTGeolocation.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 00C302BA1ABCB90400DB3ED1 /* libRCTGeolocation.a */; };
@ -35,9 +36,11 @@
2D16E6881FA4F8E400B85C8A /* libReact.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 2D16E6891FA4F8E400B85C8A /* libReact.a */; };
2DCD954D1E0B4F2C00145EB5 /* appTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 00E356F21AD99517003FC87E /* appTests.m */; };
2DF0FFEE2056DD460020B375 /* libReact.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 3DAD3EA31DF850E9000B6D8A /* libReact.a */; };
4EBB88037B054A508BF35245 /* libRNDeviceInfo.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 0F42241E0235464C91B24049 /* libRNDeviceInfo.a */; };
514DB1DF2E3B452F9EF272E3 /* libRNVectorIcons-tvOS.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 95B0A42B6CD8441E904E6EB9 /* libRNVectorIcons-tvOS.a */; };
69E1B84AE0DF486CB1B1D226 /* libBVLinearGradient.a in Frameworks */ = {isa = PBXBuildFile; fileRef = C00CE8A4E3B747F9816B91CF /* libBVLinearGradient.a */; };
832341BD1AAA6AB300B99B32 /* libRCTText.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 832341B51AAA6A8300B99B32 /* libRCTText.a */; };
A52E07192CD249F7B10FDA66 /* libAirMaps.a in Frameworks */ = {isa = PBXBuildFile; fileRef = C0906CC582484A7393F9B1F6 /* libAirMaps.a */; };
ADBDB9381DFEBF1600ED6528 /* libRCTBlob.a in Frameworks */ = {isa = PBXBuildFile; fileRef = ADBDB9271DFEBF0700ED6528 /* libRCTBlob.a */; };
BE104176D74E47E9A369B15A /* libRNVectorIcons.a in Frameworks */ = {isa = PBXBuildFile; fileRef = EB0A5A258CBE4EEFAD3C358E /* libRNVectorIcons.a */; };
BE302B6D221B7875005626CF /* libRNCamera.a in Frameworks */ = {isa = PBXBuildFile; fileRef = BE302B6C221B7860005626CF /* libRNCamera.a */; };
@ -58,9 +61,7 @@
BE5EAB86221B7D5400E92E5B /* Zocial.ttf in Resources */ = {isa = PBXBuildFile; fileRef = BE5EAB77221B7D5400E92E5B /* Zocial.ttf */; };
BE5EAC3A221B83CF00E92E5B /* Ionicons.ttf in Resources */ = {isa = PBXBuildFile; fileRef = BE302B75221B7C3B005626CF /* Ionicons.ttf */; };
BE5EAC41221B889900E92E5B /* libReactNativePermissions.a in Frameworks */ = {isa = PBXBuildFile; fileRef = BE5EAC40221B888C00E92E5B /* libReactNativePermissions.a */; };
4EBB88037B054A508BF35245 /* libRNDeviceInfo.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 0F42241E0235464C91B24049 /* libRNDeviceInfo.a */; };
E677346A94D54E90817979B0 /* libRNDeviceInfo-tvOS.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 3C4D43A092A4408B91B32E76 /* libRNDeviceInfo-tvOS.a */; };
A52E07192CD249F7B10FDA66 /* libAirMaps.a in Frameworks */ = {isa = PBXBuildFile; fileRef = C0906CC582484A7393F9B1F6 /* libAirMaps.a */; };
/* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */
@ -386,6 +387,27 @@
remoteGlobalIDString = 9D23B34F1C767B80008B4819;
remoteInfo = ReactNativePermissions;
};
BE7C0E9A223D9A43009CAF95 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 5BA133418E6F4967BC5BC234 /* RNDeviceInfo.xcodeproj */;
proxyType = 2;
remoteGlobalIDString = DA5891D81BA9A9FC002B4DB2;
remoteInfo = RNDeviceInfo;
};
BE7C0E9C223D9A43009CAF95 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 5BA133418E6F4967BC5BC234 /* RNDeviceInfo.xcodeproj */;
proxyType = 2;
remoteGlobalIDString = E72EC1401F7ABB5A0001BC90;
remoteInfo = "RNDeviceInfo-tvOS";
};
BE7C0EA1223D9A43009CAF95 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = A97F1617782E42EC83467F41 /* AirMaps.xcodeproj */;
proxyType = 2;
remoteGlobalIDString = 11FA5C511C4A1296003AC2EE;
remoteInfo = AirMaps;
};
/* End PBXContainerItemProxy section */
/* Begin PBXFileReference section */
@ -398,6 +420,7 @@
00E356EE1AD99517003FC87E /* appTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = appTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
00E356F11AD99517003FC87E /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
00E356F21AD99517003FC87E /* appTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = appTests.m; sourceTree = "<group>"; };
0F42241E0235464C91B24049 /* libRNDeviceInfo.a */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = archive.ar; path = libRNDeviceInfo.a; sourceTree = "<group>"; };
139105B61AF99BAD00B5F7CC /* RCTSettings.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTSettings.xcodeproj; path = "../node_modules/react-native/Libraries/Settings/RCTSettings.xcodeproj"; sourceTree = "<group>"; };
139FDEE61B06529A00C62182 /* RCTWebSocket.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTWebSocket.xcodeproj; path = "../node_modules/react-native/Libraries/WebSocket/RCTWebSocket.xcodeproj"; sourceTree = "<group>"; };
13B07F961A680F5B00A75B9A /* app.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = app.app; sourceTree = BUILT_PRODUCTS_DIR; };
@ -412,11 +435,14 @@
2D02E47B1E0B4A5D006451C7 /* app-tvOS.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "app-tvOS.app"; sourceTree = BUILT_PRODUCTS_DIR; };
2D02E4901E0B4A5D006451C7 /* app-tvOSTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "app-tvOSTests.xctest"; sourceTree = BUILT_PRODUCTS_DIR; };
2D16E6891FA4F8E400B85C8A /* libReact.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; path = libReact.a; sourceTree = BUILT_PRODUCTS_DIR; };
3C4D43A092A4408B91B32E76 /* libRNDeviceInfo-tvOS.a */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = archive.ar; path = "libRNDeviceInfo-tvOS.a"; sourceTree = "<group>"; };
5BA133418E6F4967BC5BC234 /* RNDeviceInfo.xcodeproj */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = "wrapper.pb-project"; name = RNDeviceInfo.xcodeproj; path = "../node_modules/react-native-device-info/ios/RNDeviceInfo.xcodeproj"; sourceTree = "<group>"; };
5E91572D1DD0AC6500FF2AA8 /* RCTAnimation.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTAnimation.xcodeproj; path = "../node_modules/react-native/Libraries/NativeAnimation/RCTAnimation.xcodeproj"; sourceTree = "<group>"; };
664970B9D10A41A18B44727F /* RNVectorIcons.xcodeproj */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = "wrapper.pb-project"; name = RNVectorIcons.xcodeproj; path = "../node_modules/react-native-vector-icons/RNVectorIcons.xcodeproj"; sourceTree = "<group>"; };
78C398B01ACF4ADC00677621 /* RCTLinking.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTLinking.xcodeproj; path = "../node_modules/react-native/Libraries/LinkingIOS/RCTLinking.xcodeproj"; sourceTree = "<group>"; };
832341B01AAA6A8300B99B32 /* RCTText.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTText.xcodeproj; path = "../node_modules/react-native/Libraries/Text/RCTText.xcodeproj"; sourceTree = "<group>"; };
95B0A42B6CD8441E904E6EB9 /* libRNVectorIcons-tvOS.a */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = archive.ar; path = "libRNVectorIcons-tvOS.a"; sourceTree = "<group>"; };
A97F1617782E42EC83467F41 /* AirMaps.xcodeproj */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = "wrapper.pb-project"; name = AirMaps.xcodeproj; path = "../node_modules/react-native-maps/lib/ios/AirMaps.xcodeproj"; sourceTree = "<group>"; };
ADBDB91F1DFEBF0600ED6528 /* RCTBlob.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTBlob.xcodeproj; path = "../node_modules/react-native/Libraries/Blob/RCTBlob.xcodeproj"; sourceTree = "<group>"; };
BE302B67221B7860005626CF /* RNCamera.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RNCamera.xcodeproj; path = "../node_modules/react-native-camera/ios/RNCamera.xcodeproj"; sourceTree = "<group>"; };
BE302B6E221B7AC7005626CF /* RNGestureHandler.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RNGestureHandler.xcodeproj; path = "../node_modules/react-native-gesture-handler/ios/RNGestureHandler.xcodeproj"; sourceTree = "<group>"; };
@ -437,12 +463,8 @@
BE5EAB77221B7D5400E92E5B /* Zocial.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; name = Zocial.ttf; path = "../node_modules/react-native-vector-icons/Fonts/Zocial.ttf"; sourceTree = "<group>"; };
BE5EAC3B221B888C00E92E5B /* ReactNativePermissions.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = ReactNativePermissions.xcodeproj; path = "../node_modules/react-native-permissions/ios/ReactNativePermissions.xcodeproj"; sourceTree = "<group>"; };
C00CE8A4E3B747F9816B91CF /* libBVLinearGradient.a */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = archive.ar; path = libBVLinearGradient.a; sourceTree = "<group>"; };
C0906CC582484A7393F9B1F6 /* libAirMaps.a */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = archive.ar; path = libAirMaps.a; sourceTree = "<group>"; };
EB0A5A258CBE4EEFAD3C358E /* libRNVectorIcons.a */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = archive.ar; path = libRNVectorIcons.a; sourceTree = "<group>"; };
5BA133418E6F4967BC5BC234 /* RNDeviceInfo.xcodeproj */ = {isa = PBXFileReference; name = "RNDeviceInfo.xcodeproj"; path = "../node_modules/react-native-device-info/ios/RNDeviceInfo.xcodeproj"; sourceTree = "<group>"; fileEncoding = undefined; lastKnownFileType = wrapper.pb-project; explicitFileType = undefined; includeInIndex = 0; };
0F42241E0235464C91B24049 /* libRNDeviceInfo.a */ = {isa = PBXFileReference; name = "libRNDeviceInfo.a"; path = "libRNDeviceInfo.a"; sourceTree = "<group>"; fileEncoding = undefined; lastKnownFileType = archive.ar; explicitFileType = undefined; includeInIndex = 0; };
3C4D43A092A4408B91B32E76 /* libRNDeviceInfo-tvOS.a */ = {isa = PBXFileReference; name = "libRNDeviceInfo-tvOS.a"; path = "libRNDeviceInfo-tvOS.a"; sourceTree = "<group>"; fileEncoding = undefined; lastKnownFileType = archive.ar; explicitFileType = undefined; includeInIndex = 0; };
A97F1617782E42EC83467F41 /* AirMaps.xcodeproj */ = {isa = PBXFileReference; name = "AirMaps.xcodeproj"; path = "../node_modules/react-native-maps/lib/ios/AirMaps.xcodeproj"; sourceTree = "<group>"; fileEncoding = undefined; lastKnownFileType = wrapper.pb-project; explicitFileType = undefined; includeInIndex = 0; };
C0906CC582484A7393F9B1F6 /* libAirMaps.a */ = {isa = PBXFileReference; name = "libAirMaps.a"; path = "libAirMaps.a"; sourceTree = "<group>"; fileEncoding = undefined; lastKnownFileType = archive.ar; explicitFileType = undefined; includeInIndex = 0; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
@ -765,6 +787,9 @@
EB0A5A258CBE4EEFAD3C358E /* libRNVectorIcons.a */,
95B0A42B6CD8441E904E6EB9 /* libRNVectorIcons-tvOS.a */,
C00CE8A4E3B747F9816B91CF /* libBVLinearGradient.a */,
0F42241E0235464C91B24049 /* libRNDeviceInfo.a */,
C0906CC582484A7393F9B1F6 /* libAirMaps.a */,
3C4D43A092A4408B91B32E76 /* libRNDeviceInfo-tvOS.a */,
);
name = "Recovered References";
sourceTree = "<group>";
@ -795,6 +820,23 @@
name = Products;
sourceTree = "<group>";
};
BE7C0E96223D9A42009CAF95 /* Products */ = {
isa = PBXGroup;
children = (
BE7C0E9B223D9A43009CAF95 /* libRNDeviceInfo.a */,
BE7C0E9D223D9A43009CAF95 /* libRNDeviceInfo-tvOS.a */,
);
name = Products;
sourceTree = "<group>";
};
BE7C0E9E223D9A43009CAF95 /* Products */ = {
isa = PBXGroup;
children = (
BE7C0EA2223D9A43009CAF95 /* libAirMaps.a */,
);
name = Products;
sourceTree = "<group>";
};
/* End PBXGroup section */
/* Begin PBXNativeTarget section */
@ -881,6 +923,7 @@
TargetAttributes = {
00E356ED1AD99517003FC87E = {
CreatedOnToolsVersion = 6.2;
DevelopmentTeam = HLA62A6826;
TestTargetID = 13B07F861A680F5B00A75B9A;
};
13B07F861A680F5B00A75B9A = {
@ -888,6 +931,7 @@
};
2D02E47A1E0B4A5D006451C7 = {
CreatedOnToolsVersion = 8.2.1;
DevelopmentTeam = HLA62A6826;
ProvisioningStyle = Automatic;
};
2D02E48F1E0B4A5D006451C7 = {
@ -909,6 +953,10 @@
productRefGroup = 83CBBA001A601CBA00E9B192 /* Products */;
projectDirPath = "";
projectReferences = (
{
ProductGroup = BE7C0E9E223D9A43009CAF95 /* Products */;
ProjectRef = A97F1617782E42EC83467F41 /* AirMaps.xcodeproj */;
},
{
ProductGroup = BE5EAC32221B835A00E92E5B /* Products */;
ProjectRef = 1908F5E093844AC5A143E888 /* BVLinearGradient.xcodeproj */;
@ -969,6 +1017,10 @@
ProductGroup = BE302B68221B7860005626CF /* Products */;
ProjectRef = BE302B67221B7860005626CF /* RNCamera.xcodeproj */;
},
{
ProductGroup = BE7C0E96223D9A42009CAF95 /* Products */;
ProjectRef = 5BA133418E6F4967BC5BC234 /* RNDeviceInfo.xcodeproj */;
},
{
ProductGroup = BE302B6F221B7AC7005626CF /* Products */;
ProjectRef = BE302B6E221B7AC7005626CF /* RNGestureHandler.xcodeproj */;
@ -1297,6 +1349,27 @@
remoteRef = BE5EAC3F221B888C00E92E5B /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
BE7C0E9B223D9A43009CAF95 /* libRNDeviceInfo.a */ = {
isa = PBXReferenceProxy;
fileType = archive.ar;
path = libRNDeviceInfo.a;
remoteRef = BE7C0E9A223D9A43009CAF95 /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
BE7C0E9D223D9A43009CAF95 /* libRNDeviceInfo-tvOS.a */ = {
isa = PBXReferenceProxy;
fileType = archive.ar;
path = "libRNDeviceInfo-tvOS.a";
remoteRef = BE7C0E9C223D9A43009CAF95 /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
BE7C0EA2223D9A43009CAF95 /* libAirMaps.a */ = {
isa = PBXReferenceProxy;
fileType = archive.ar;
path = libAirMaps.a;
remoteRef = BE7C0EA1223D9A43009CAF95 /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
/* End PBXReferenceProxy section */
/* Begin PBXResourcesBuildPhase section */
@ -1446,6 +1519,7 @@
isa = XCBuildConfiguration;
buildSettings = {
BUNDLE_LOADER = "$(TEST_HOST)";
DEVELOPMENT_TEAM = HLA62A6826;
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
"$(inherited)",
@ -1455,7 +1529,7 @@
"$(SRCROOT)/../node_modules/react-native-vector-icons/RNVectorIconsManager",
"$(SRCROOT)/../node_modules/react-native-linear-gradient/BVLinearGradient",
"$(SRCROOT)/../node_modules/react-native-device-info/ios/RNDeviceInfo",
"$(SRCROOT)\..\node_modules\react-native-maps\lib\ios/**",
"$(SRCROOT)..\node_modules\neact-native-mapslibios/**",
);
INFOPLIST_FILE = appTests/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
@ -1484,12 +1558,13 @@
buildSettings = {
BUNDLE_LOADER = "$(TEST_HOST)";
COPY_PHASE_STRIP = NO;
DEVELOPMENT_TEAM = HLA62A6826;
HEADER_SEARCH_PATHS = (
"$(inherited)",
"$(SRCROOT)/../node_modules/react-native-vector-icons/RNVectorIconsManager",
"$(SRCROOT)/../node_modules/react-native-linear-gradient/BVLinearGradient",
"$(SRCROOT)/../node_modules/react-native-device-info/ios/RNDeviceInfo",
"$(SRCROOT)\..\node_modules\react-native-maps\lib\ios/**",
"$(SRCROOT)..\node_modules\neact-native-mapslibios/**",
);
INFOPLIST_FILE = appTests/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
@ -1525,7 +1600,7 @@
"$(SRCROOT)/../node_modules/react-native-vector-icons/RNVectorIconsManager",
"$(SRCROOT)/../node_modules/react-native-linear-gradient/BVLinearGradient",
"$(SRCROOT)/../node_modules/react-native-device-info/ios/RNDeviceInfo",
"$(SRCROOT)\..\node_modules\react-native-maps\lib\ios/**",
"$(SRCROOT)..\node_modules\neact-native-mapslibios/**",
);
INFOPLIST_FILE = app/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
@ -1551,7 +1626,7 @@
"$(SRCROOT)/../node_modules/react-native-vector-icons/RNVectorIconsManager",
"$(SRCROOT)/../node_modules/react-native-linear-gradient/BVLinearGradient",
"$(SRCROOT)/../node_modules/react-native-device-info/ios/RNDeviceInfo",
"$(SRCROOT)\..\node_modules\react-native-maps\lib\ios/**",
"$(SRCROOT)..\node_modules\neact-native-mapslibios/**",
);
INFOPLIST_FILE = app/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
@ -1576,6 +1651,7 @@
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
DEBUG_INFORMATION_FORMAT = dwarf;
DEVELOPMENT_TEAM = HLA62A6826;
ENABLE_TESTABILITY = YES;
GCC_NO_COMMON_BLOCKS = YES;
HEADER_SEARCH_PATHS = (
@ -1583,7 +1659,7 @@
"$(SRCROOT)/../node_modules/react-native-vector-icons/RNVectorIconsManager",
"$(SRCROOT)/../node_modules/react-native-linear-gradient/BVLinearGradient",
"$(SRCROOT)/../node_modules/react-native-device-info/ios/RNDeviceInfo",
"$(SRCROOT)\..\node_modules\react-native-maps\lib\ios/**",
"$(SRCROOT)..\node_modules\neact-native-mapslibios/**",
);
INFOPLIST_FILE = "app-tvOS/Info.plist";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
@ -1619,13 +1695,14 @@
CLANG_WARN_SUSPICIOUS_MOVE = YES;
COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
DEVELOPMENT_TEAM = HLA62A6826;
GCC_NO_COMMON_BLOCKS = YES;
HEADER_SEARCH_PATHS = (
"$(inherited)",
"$(SRCROOT)/../node_modules/react-native-vector-icons/RNVectorIconsManager",
"$(SRCROOT)/../node_modules/react-native-linear-gradient/BVLinearGradient",
"$(SRCROOT)/../node_modules/react-native-device-info/ios/RNDeviceInfo",
"$(SRCROOT)\..\node_modules\react-native-maps\lib\ios/**",
"$(SRCROOT)..\node_modules\neact-native-mapslibios/**",
);
INFOPLIST_FILE = "app-tvOS/Info.plist";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
@ -1666,7 +1743,7 @@
"$(SRCROOT)/../node_modules/react-native-vector-icons/RNVectorIconsManager",
"$(SRCROOT)/../node_modules/react-native-linear-gradient/BVLinearGradient",
"$(SRCROOT)/../node_modules/react-native-device-info/ios/RNDeviceInfo",
"$(SRCROOT)\..\node_modules\react-native-maps\lib\ios/**",
"$(SRCROOT)..\node_modules\neact-native-mapslibios/**",
);
INFOPLIST_FILE = "app-tvOSTests/Info.plist";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
@ -1707,7 +1784,7 @@
"$(SRCROOT)/../node_modules/react-native-vector-icons/RNVectorIconsManager",
"$(SRCROOT)/../node_modules/react-native-linear-gradient/BVLinearGradient",
"$(SRCROOT)/../node_modules/react-native-device-info/ios/RNDeviceInfo",
"$(SRCROOT)\..\node_modules\react-native-maps\lib\ios/**",
"$(SRCROOT)..\node_modules\neact-native-mapslibios/**",
);
INFOPLIST_FILE = "app-tvOSTests/Info.plist";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";

View File

@ -24,7 +24,7 @@ namespace api.Controllers
private readonly IMapper _mapper;
private readonly RoleManager<Role> _roleManager;
private readonly UserManager<User> _userManager;
public TeamsController(DataContext context,ITeamsRepository repo, IMapper mapper,RoleManager<Role> roleManager,UserManager<User> UserManager)
public TeamsController(DataContext context, ITeamsRepository repo, IMapper mapper, RoleManager<Role> roleManager, UserManager<User> UserManager)
{
this.context = context;
_mapper = mapper;
@ -32,26 +32,27 @@ namespace api.Controllers
_userManager = UserManager;
_repo = repo;
}
// GET api/teams
// GET all teams
[HttpGet]
public async Task<List<TeamToReturn>> GetTeams()
{
List<Team> allTeams = await context.Teams.ToListAsync();
List<TeamToReturn> rTeams = new List<TeamToReturn>();
List<Team> allTeams = await context.Teams.ToListAsync();
List<TeamToReturn> rTeams = new List<TeamToReturn>();
for(var i = 0; i < allTeams.Count;i++){
TeamToReturn tR = new TeamToReturn();
_mapper.Map(allTeams[i],tR);
var usr = await context.Users.FirstOrDefaultAsync(a=>a.QRcode == allTeams[i].CapQR);
UserForListDto uT = new UserForListDto();
_mapper.Map(usr,uT);
tR.Cap = uT;
rTeams.Add(tR);
}
for (var i = 0; i < allTeams.Count; i++)
{
TeamToReturn tR = new TeamToReturn();
_mapper.Map(allTeams[i], tR);
var usr = await context.Users.FirstOrDefaultAsync(a => a.QRcode == allTeams[i].CapQR);
UserForListDto uT = new UserForListDto();
_mapper.Map(usr, uT);
tR.Cap = uT;
rTeams.Add(tR);
}
return rTeams;
return rTeams;
}
// GET api/teams/e/[id]
@ -59,44 +60,80 @@ namespace api.Controllers
[HttpGet("e/{id}")]
public async Task<List<TeamToReturn>> GetTeamsEvent(int id)
{
List<Team> allTeams = await context.Teams.ToListAsync();
List<TeamToReturn> rTeam = new List<TeamToReturn>();
TeamToReturn tR = new TeamToReturn();
List<Team> allTeams = await context.Teams.ToListAsync();
List<TeamToReturn> rTeam = new List<TeamToReturn>();
TeamToReturn tR = new TeamToReturn();
for(var i = 0; i < allTeams.Count;i++){
if(allTeams[i].EventId == id){
_mapper.Map(allTeams[i],tR);
var usr = await context.Users.FirstOrDefaultAsync(a=>a.QRcode == allTeams[i].CapQR);
UserForListDto uT = new UserForListDto();
_mapper.Map(usr,uT);
tR.Cap = uT;
rTeam.Add(tR);
}
}
return rTeam;
for (var i = 0; i < allTeams.Count; i++)
{
if (allTeams[i].EventId == id)
{
_mapper.Map(allTeams[i], tR);
var usr = await context.Users.FirstOrDefaultAsync(a => a.QRcode == allTeams[i].CapQR);
UserForListDto uT = new UserForListDto();
_mapper.Map(usr, uT);
tR.Cap = uT;
rTeam.Add(tR);
}
}
return rTeam;
}
// GET api/teams/u/[id]
// GET all teams for user id
[HttpGet("u/{QR}")]
public async Task<TeamToReturn> GetTeamsUser(String QR)
public async Task<IActionResult> GetTeamsUser(String QR)
{
var rUsr = await context.Users.Include(b=>b.team).FirstOrDefaultAsync(a=>a.QRcode == QR);
List<Team> allTeams = await context.Teams.ToListAsync();
TeamToReturn rTeam = new TeamToReturn();
var rUsr = await context.Users.Include(b => b.team).FirstOrDefaultAsync(a => a.QRcode == QR);
for(var i = 0; i < allTeams.Count;i++){
if(allTeams[i].Id == rUsr.team.Id){
_mapper.Map(allTeams[i],rTeam);
var usr = await context.Users.FirstOrDefaultAsync(a=>a.QRcode == allTeams[i].CapQR);
UserForListDto uT = new UserForListDto();
_mapper.Map(usr,uT);
rTeam.Cap = uT;
}
}
return rTeam;
if (rUsr == null)
{
return NotFound("O utilizador não possui equipa");
}
List<Team> allTeams = await context.Teams.ToListAsync();
TeamToReturn rTeam = new TeamToReturn();
for (var i = 0; i < allTeams.Count; i++)
{
if (allTeams[i].Id == rUsr.team.Id)
{
_mapper.Map(allTeams[i], rTeam);
var usr = await context.Users.FirstOrDefaultAsync(a => a.QRcode == allTeams[i].CapQR);
var users = await context.Users.ToListAsync();
List<UserForListDto> usersToReturn= new List<UserForListDto>();
for (var t = 0; t < users.Count; t++){
if(users[t].team!= null && users[t].team.Id == allTeams[i].Id){
UserForListDto u = new UserForListDto();
_mapper.Map(users[t], u);
usersToReturn.Add(u);
}
}
UserForListDto uT = new UserForListDto();
_mapper.Map(usr, uT);
rTeam.Membros= usersToReturn;
rTeam.Cap = uT;
}
}
return Ok(rTeam);
}
// POST api/teams/add
@ -105,27 +142,31 @@ namespace api.Controllers
public async Task<IActionResult> CreateTeam(TeamForAdd TeamAddDetails)
{
User tCap = await context.Users.Include(a=>a.team).FirstOrDefaultAsync(u=>u.QRcode == TeamAddDetails.capQR);
if(tCap.team == null){
Team tAdd = new Team{EventId = TeamAddDetails.EventId, Nome = TeamAddDetails.Nome, CapQR = tCap.QRcode, NMembros = 1, Pontos = 0};
User tCap = await context.Users.Include(a => a.team).FirstOrDefaultAsync(u => u.QRcode == TeamAddDetails.capQR);
tCap.team = tAdd;
if (tCap.team == null)
{
await context.Teams.AddAsync(tAdd);
context.Users.Update(tCap);
Team tAdd = new Team { EventId = TeamAddDetails.EventId, Nome = TeamAddDetails.Nome, CapQR = tCap.QRcode, NMembros = 1, Pontos = 0 };
tCap.team = tAdd;
await context.Teams.AddAsync(tAdd);
context.Users.Update(tCap);
var result = context.SaveChanges();
if (result >= 1)
{
return StatusCode(201);
}
return BadRequest();
}
else
{
return BadRequest();
}
var result = context.SaveChanges();
if (result >= 1)
{
return StatusCode(201);
}
return BadRequest();
}else{
return BadRequest();
}
}
// POST api/teams/add/member
@ -134,25 +175,29 @@ namespace api.Controllers
public async Task<IActionResult> AddTeamMember(TeamAddMember MemberToAdd)
{
User newMember = await context.Users.FirstOrDefaultAsync(u=>u.QRcode == MemberToAdd.newQR);
User newMember = await context.Users.FirstOrDefaultAsync(u => u.QRcode == MemberToAdd.newQR);
Team tEdit = await context.Teams.FirstOrDefaultAsync(t=>t.Id == MemberToAdd.id);
Team tEdit = await context.Teams.FirstOrDefaultAsync(t => t.Id == MemberToAdd.id);
if(newMember.team == null){
tEdit.NMembros++;
newMember.team = tEdit;
if (newMember.team == null)
{
context.Teams.Update(tEdit);
context.Users.Update(newMember);
tEdit.NMembros++;
newMember.team = tEdit;
var result = context.SaveChanges();
context.Teams.Update(tEdit);
context.Users.Update(newMember);
return StatusCode(201);
var result = context.SaveChanges();
return StatusCode(201);
}
else
{
return StatusCode(403);
}
}else{
return StatusCode(403);
}
}
// POST api/teams/ChangeName
@ -161,20 +206,21 @@ namespace api.Controllers
public async Task<IActionResult> ChangeName(TeamChangeName NameChange)
{
Team tEdit = await context.Teams.FirstOrDefaultAsync(t=>t.Id == NameChange.TeamID);
Team tEdit = await context.Teams.FirstOrDefaultAsync(t => t.Id == NameChange.TeamID);
User cap = await context.Users.FirstOrDefaultAsync(u=>u.QRcode == NameChange.UserQR);
User cap = await context.Users.FirstOrDefaultAsync(u => u.QRcode == NameChange.UserQR);
if(cap.QRcode == tEdit.CapQR){
tEdit.Nome = NameChange.nome;
}
if (cap.QRcode == tEdit.CapQR)
{
tEdit.Nome = NameChange.nome;
}
context.Teams.Update(tEdit);
context.Teams.Update(tEdit);
var result = context.SaveChanges();
return StatusCode(201);
var result = context.SaveChanges();
return StatusCode(201);
}
// POST api/teams/delete
@ -183,19 +229,22 @@ namespace api.Controllers
public async Task<IActionResult> DeleteTeam(TeamDelete DeleteData)
{
Team tEdit = await context.Teams.FirstOrDefaultAsync(t=>t.Id == DeleteData.TeamID);
Team tEdit = await context.Teams.FirstOrDefaultAsync(t => t.Id == DeleteData.TeamID);
User cap = await context.Users.FirstOrDefaultAsync(u=>u.QRcode == DeleteData.UserQR);
User cap = await context.Users.FirstOrDefaultAsync(u => u.QRcode == DeleteData.UserQR);
if(cap.QRcode == tEdit.CapQR){
context.Teams.Remove(tEdit);
cap.team = null;
context.Users.Update(cap);
var result = context.SaveChanges();
return StatusCode(201);
}else{
return StatusCode(403);
}
if (cap.QRcode == tEdit.CapQR)
{
context.Teams.Remove(tEdit);
cap.team = null;
context.Users.Update(cap);
var result = context.SaveChanges();
return StatusCode(201);
}
else
{
return StatusCode(403);
}
}
// POST api/teams/remove/member
@ -204,28 +253,32 @@ namespace api.Controllers
public async Task<IActionResult> RemoveTeamMember(TeamRemoveMEmber MemberToRemove)
{
User rmMember = await context.Users.FirstOrDefaultAsync(u=>u.QRcode == MemberToRemove.UserToRemoveQR);
User rmMember = await context.Users.FirstOrDefaultAsync(u => u.QRcode == MemberToRemove.UserToRemoveQR);
Team tEdit = await context.Teams.FirstOrDefaultAsync(t=>t.Id == MemberToRemove.TeamID);
Team tEdit = await context.Teams.FirstOrDefaultAsync(t => t.Id == MemberToRemove.TeamID);
if(rmMember.QRcode == tEdit.CapQR){
return StatusCode(403);
}
if (rmMember.QRcode == tEdit.CapQR)
{
return StatusCode(403);
}
if(rmMember.team == tEdit){
tEdit.NMembros--;
rmMember.team = null;
if (rmMember.team == tEdit)
{
tEdit.NMembros--;
rmMember.team = null;
context.Teams.Update(tEdit);
context.Users.Update(rmMember);
context.Teams.Update(tEdit);
context.Users.Update(rmMember);
var result = context.SaveChanges();
return StatusCode(201);
}
else
{
return StatusCode(403);
}
var result = context.SaveChanges();
return StatusCode(201);
}else{
return StatusCode(403);
}
}
}
}

View File

@ -1,3 +1,4 @@
using System;
using System.Collections.Generic;
using System.Security.Claims;
using System.Threading.Tasks;
@ -22,7 +23,7 @@ namespace api.Controllers
private readonly RoleManager<Role> _roleManager;
private readonly UserManager<User> _userManager;
public UsersController(IUsersRepository repo, IMapper mapper,RoleManager<Role> roleManager,UserManager<User> UserManager)
public UsersController(IUsersRepository repo, IMapper mapper, RoleManager<Role> roleManager, UserManager<User> UserManager)
{
_mapper = mapper;
_roleManager = roleManager;
@ -30,35 +31,56 @@ namespace api.Controllers
_repo = repo;
}
//
[HttpGet("{id}")]
public async Task<IActionResult> GetUser(int id)
{
var user = await _repo.GetUser(id);
var userToReturn = _mapper.Map<UserForDetailedDto>(user);
return Ok(userToReturn);
}
[Authorize(Policy= "RequireAdminRole")]
[Authorize(Policy = "RequireAdminRole")]
[HttpGet]
public async Task<IActionResult> GetUsers()
{
var users = await _repo.GetUsers();
var usersToReturn = _mapper.Map<IEnumerable<UserForListDto>>(users);
return Ok(usersToReturn);
}
[Authorize(Policy = "RequireAdminRole")]
[HttpPost("updateAll")]
public async Task<IActionResult> UpdateUsers(updateUsersDTO[] req)
{
try
{
foreach (var user in req)
{
}
return Ok(req);
}
catch (Exception e)
{
}
return Ok();
}
[HttpPut("{id}")]
public async Task<IActionResult> UpdateUser(int id, UserForUpdateDto userForUpdate){
public async Task<IActionResult> UpdateUser(int id, UserForUpdateDto userForUpdate)
{
if (id != int.Parse(User.FindFirst(ClaimTypes.NameIdentifier).Value))
return Unauthorized(); //garante que é o próprio pode aceder à sua informação
@ -66,36 +88,38 @@ namespace api.Controllers
_mapper.Map(userForUpdate, userFromRepo);
if(await _repo.SaveAll())
if (await _repo.SaveAll())
return NoContent();
throw new System.Exception($"updating user {id} failed on save");
}
[HttpPut("update/{id}")]
[Authorize(Policy= "RequireAdminRole")]
public async Task<IActionResult> UpdateUserById(int id, UserForUpdateDto userForUpdate){
[Authorize(Policy = "RequireAdminRole")]
public async Task<IActionResult> UpdateUserById(int id, UserForUpdateDto userForUpdate)
{
var userFromRepo = await _repo.GetUser(id);
_mapper.Map(userForUpdate, userFromRepo);
if(await _repo.SaveAll())
if (await _repo.SaveAll())
return NoContent();
throw new System.Exception($"updating user {id} failed on save");
}
//adiciona uma nova role à base de dados
[Authorize(Policy= "RequireAdminRole")]
[Authorize(Policy = "RequireAdminRole")]
[HttpPost("addRole")]
public IActionResult addRole( Role role) {
public IActionResult addRole(Role role)
{
_roleManager.CreateAsync(role).Wait();
return Ok();
}

View File

@ -12,6 +12,8 @@ namespace api.Dtos
public string Nome{get;set;} //Nome da equipa
public UserForListDto Cap{get;set;} //Capitao da equipa
public int NMembros {get;set;} //Numero de Membros na equipa
public List<UserForListDto> Membros{get;set;}
public int Pontos {get;set;} //Postos da equipa
}
}

View File

@ -0,0 +1,9 @@
using System.Collections.Generic;
namespace api.Dtos
{
public class updateJSONdto
{
public List<updateUsersDTO> users{get;set;}
}
}

View File

@ -0,0 +1,10 @@
namespace api.Dtos
{
public class updateUsersDTO
{
public string barcode { get; set; }
public string email { get; set; }
public string name { get; set; }
public string extra1 { get; set; }
}
}

View File

@ -9,7 +9,8 @@ namespace api.Models
{
public class User: IdentityUser<int>
{
// public string fullName{get;set;}
// public string university{get;set;}
public string QRcode{get;set;}
public ICollection<UserRole> UserRoles{get;set;}
public ICollection<Log> logsFebrada{get;set;}

View File

@ -1,5 +1,5 @@
{
"ProjectFilePath": "c:\\Users\\ZMiguel\\Desktop\\ENEI2019\\api\\api.csproj",
"ProjectFilePath": "/Users/henrique/ENEI2019/api/api.csproj",
"TargetFramework": "netcoreapp2.1",
"TagHelpers": [],
"Configuration": {