This commit is contained in:
henrydays 2019-03-14 19:49:24 +00:00
commit 6214aea437
12 changed files with 230 additions and 5 deletions

View File

@ -183,6 +183,7 @@ const Stack = createStackNavigator({
return {
headerTitle: 'Eventos',
}
}
else {
return {
@ -207,7 +208,6 @@ const Stack = createStackNavigator({
screen: FebradaDetail,
},
resetPassword:{
screen:resetPassword
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.6 KiB

View File

@ -1,11 +1,15 @@
import * as React from "react";
import {View, StyleSheet, Dimensions, Text, Button, ScrollView, Image, TouchableOpacity} from "react-native";
import {TabView, TabBar, SceneMap} from "react-native-tab-view";
import rallyImg from '../assets/rallyTascas.jpg';
const SCREEN_HEIGHT = Dimensions.get("window").height;
const SCREEN_WIDTH = Dimensions.get("window").width;
const FirstRoute = () => (
<View style={[styles.scene, {backgroundColor: "#ff4081"}]}/>
);
@ -51,7 +55,6 @@ export default class Eventos extends React.Component {
</Image>
</View>
</TouchableOpacity>
</View>
);
@ -128,6 +131,7 @@ const styles = StyleSheet.create({
cardContainer: {
flex: 1,
flexDirection: 'row',
padding: 10,
margin: 20,
backgroundColor: '#fff',

View File

@ -0,0 +1,47 @@
/*
/*
/*
/*Esta página só está disponivel a 1 hora do rally..
*/
import * as React from "react";
import {View, StyleSheet, Dimensions, Text, Button, ScrollView} from "react-native";
import {TabView, TabBar, SceneMap} from "react-native-tab-view";
import * as Actions from "../store/actions";
import {connect} from "react-redux";
import {bindActionCreators} from "redux";
export default class rallyTascas extends React.Component {
render() {
return (
<View>
</View>
)
}
}
function mapStateToProps(state, props) {
return {
token: state.apiReducer.token,
user: state.apiReducer.user,
logged: state.apiReducer.logged,
events: state.apiReducer.events
}
}
function mapDispatchToProps(dispatch) {
return bindActionCreators(Actions, dispatch);
}
export default connect(mapStateToProps, mapDispatchToProps)(rallyTascas);

View File

@ -0,0 +1,55 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using api.Data;
using api.Dtos;
using api.Models;
using AutoMapper;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
namespace api.Controllers
{
[Authorize]
[Route("api/[controller]")]
[ApiController]
public class CromosController : ControllerBase
{
private readonly DataContext context;
private readonly IMapper _mapper;
public CromosController(DataContext context, IMapper mapper)
{
this.context = context;
_mapper = mapper;
}
// GET api/cromos/QR
// GET cromos do user QR
[HttpGet]
public async Task<List<Cromos>> GetCromos(string QR)
{
var usr = await context.Users.Include(a=>a.cromos).FirstOrDefaultAsync(u=>u.QRcode == QR);
var allCromos = await context.Cromos.ToListAsync();
List<Cromos> rList = new List<Cromos>();
allCromos.ForEach(delegate(Cromos c){
usr.cromos.ForEach(delegate(int cid){
if(c.Id == cid){ //user tem o cromo
Cromos toAdd = new Cromos{Id = c.Id,Nome=c.Nome,DescMostrar=c.DescUnlocked,QRCode=c.QRCode,img=c.img};
rList.Add(toAdd);
}else{ //user NAO tem o cromo
Cromos toAdd = new Cromos{Id = c.Id,Nome=c.Nome,DescMostrar=c.DescLocked,QRCode=c.QRCode,img=c.img};
rList.Add(toAdd);
}
});
});
return rList;
}
}
}

View File

@ -0,0 +1,68 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using api.Data;
using api.Dtos;
using api.Models;
using AutoMapper;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
namespace api.Controllers
{
[Authorize]
[Route("api/[controller]")]
[ApiController]
public class ScanController : ControllerBase
{
private readonly DataContext context;
private readonly IMapper _mapper;
public ScanController(DataContext context, IMapper mapper)
{
this.context = context;
_mapper = mapper;
}
// PSOT api/scan
// POST scan de QR code
[HttpPost]
public async Task<ScanReturn> doScan(QRToScan ScanData)
{
User usr = await context.Users.Include(a=>a.cromos).FirstOrDefaultAsync(b=>b.QRcode == ScanData.UserQR);
var allUsers = await context.Users.ToListAsync();
var allCromos = await context.Cromos.ToListAsync();
var userAProcurar = await context.Users.FirstOrDefaultAsync(c=>c.QRcode == ScanData.ScanQR);
ScanReturn toReturn = new ScanReturn();
if(userAProcurar != null){
_mapper.Map(toReturn.user,userAProcurar);
toReturn.tipo=1;
return toReturn;
}else{
allCromos.ForEach(delegate(Cromos c){
if(c.QRCode == ScanData.ScanQR){
toReturn.tipo=0;
usr.cromos.Add(c.Id);
context.Users.Update(usr);
context.SaveChanges();
toReturn.resp = "Cromo Adicionado!";
}
});
return toReturn;
}
toReturn.tipo = -1;
return toReturn;
}
}
}

View File

@ -21,6 +21,8 @@ namespace api.Data
public DbSet<EventLoc> EventLocs {get;set;}
public DbSet<EventLocVisited> EventLocsVisited {get;set;}
public DbSet<Cromos> Cromos {get;set;}
public DbSet<Log>Logs{get;set;}

16
api/Dtos/QRToScan.cs Normal file
View File

@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using api.Models;
namespace api.Dtos
{
public class QRToScan
{
[Required]
public string UserQR{get;set;} //QR do User que ler
[Required]
public string ScanQR{get;set;} //QR a analisar
}
}

16
api/Dtos/ScanReturn.cs Normal file
View File

@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using api.Models;
namespace api.Dtos
{
public class ScanReturn
{
public int tipo{get;set;} //tipo de retorno, 0 = cromo // 1 = user
public UserForListDto user{get;set;} //user
public string resp{get;set;} //reposta
}
}

View File

@ -18,8 +18,5 @@ namespace api.Dtos
public string ProfileIcon {get;set;}
public string About{get;set;}
public string PhotoUrl{get;set;}
}
}

18
api/Models/Cromos.cs Normal file
View File

@ -0,0 +1,18 @@
using System;
using System.Collections.Generic;
namespace api.Models
{
public class Cromos
{
public int Id{get;set;} //id
public String QRCode{get;set;} //QR
public String Nome{get;set;} //Nome
public String DescLocked{get;set;} //descrição nao visto
public String DescUnlocked{get;set;}//descrição visto
public String DescMostrar{get;set;} //descrição a mostrar
public Photo img {get;set;} //imagem
}
}

View File

@ -20,6 +20,8 @@ namespace api.Models
[ForeignKey("teamID")]
public Team team{get;set;}
public List<int> cromos {get;set;}
}
}