Merge pull request #30 from henrydays/zmiguel

Zmiguel
This commit is contained in:
Henrique Dias 2019-03-16 19:34:03 +00:00 committed by GitHub
commit 435975feda
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
17 changed files with 304 additions and 230 deletions

View File

@ -29,24 +29,26 @@ namespace api.Controllers
// GET api/cromos/QR
// GET cromos do user QR
[HttpGet]
[HttpGet("{QR}")]
public async Task<List<Cromos>> GetCromos(string QR)
{
var usr = await context.Users.Include(a=>a.cromos).FirstOrDefaultAsync(u=>u.QRcode == QR);
var usr = await context.Users.FirstOrDefaultAsync(u=>u.QRcode == QR);
string[] usrCromos = usr.cromos.Substring(1).Split(",");
Console.WriteLine(usrCromos[0]);
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
for(int i=0;i<usrCromos.Length;i++){
if(Int32.Parse(usrCromos[i])==c.Id){
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

@ -50,7 +50,7 @@ namespace api.Controllers
return Ok(Teams);
}
// GET api/EventLocs/[id]
// GET api/EventLocs/e/[id]
[HttpGet("e/{id}")]
public async Task<IActionResult> GetEventLocEvent(int id)
{

View File

@ -67,7 +67,7 @@ namespace api.Controllers
public async Task<IActionResult> AddEventLoc(EventLocVisitedAdd EventLocVisitedData)
{
EventLoc Loc = await context.EventLocs.FirstOrDefaultAsync(a=>a.Id == EventLocVisitedData.EventLocID);
var userT = await context.Users.FirstOrDefaultAsync(u=>u.QRcode==EventLocVisitedData.USerQR);
var userT = await context.Users.Include(a=>a.team).FirstOrDefaultAsync(u=>u.QRcode==EventLocVisitedData.UserQR);
if(userT.team == null){
return StatusCode(403);

View File

@ -32,23 +32,25 @@ namespace api.Controllers
[HttpPost]
public async Task<ScanReturn> doScan(QRToScan ScanData)
{
User usr = await context.Users.Include(a=>a.cromos).FirstOrDefaultAsync(b=>b.QRcode == ScanData.UserQR);
User usr = await context.Users.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();
ScanReturn toReturn = new ScanReturn{tipo = -1};
if(userAProcurar != null){
_mapper.Map(toReturn.user,userAProcurar);
UserForListDto ru = new UserForListDto();
_mapper.Map(userAProcurar,ru);
toReturn.user = ru;
toReturn.tipo=1;
return toReturn;
}else{
allCromos.ForEach(delegate(Cromos c){
if(c.QRCode == ScanData.ScanQR){
toReturn.tipo=0;
usr.cromos.Add(c.Id);
usr.cromos = usr.cromos + "," + c.Id;
context.Users.Update(usr);
context.SaveChanges();
@ -59,9 +61,7 @@ namespace api.Controllers
return toReturn;
}
toReturn.tipo = -1;
return toReturn;
//return toReturn;
}
}

View File

@ -36,28 +36,67 @@ namespace api.Controllers
// GET api/teams
// GET all teams
[HttpGet]
public async Task<IActionResult> GetTeams()
public async Task<List<TeamToReturn>> GetTeams()
{
var Teams = await _repo.GetTeams();
return Ok(Teams);
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);
}
return rTeams;
}
// GET api/teams/e/[id]
// GET all teams for event id
[HttpGet("e/{id}")]
public async Task<IActionResult> GetTeamsEvent(int id)
public async Task<List<TeamToReturn>> GetTeamsEvent(int id)
{
var Teams = await _repo.GetEventTeam(id);
return Ok(Teams);
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;
}
// GET api/teams/e/[id]
// GET all teams for event id
// GET api/teams/u/[id]
// GET all teams for user id
[HttpGet("u/{QR}")]
public async Task<IActionResult> GetTeamsUser(String QR)
public async Task<TeamToReturn> GetTeamsUser(String QR)
{
var Teams = await _repo.GetUserTeam(QR);
return Ok(Teams);
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();
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;
}
// POST api/teams/add
@ -66,10 +105,10 @@ namespace api.Controllers
public async Task<IActionResult> CreateTeam(TeamForAdd TeamAddDetails)
{
User tCap = await context.Users.FirstOrDefaultAsync(u=>u.QRcode == TeamAddDetails.capQR);
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, Cap = tCap, NMembros = 1, Pontos = 0};
Team tAdd = new Team{EventId = TeamAddDetails.EventId, Nome = TeamAddDetails.Nome, CapQR = tCap.QRcode, NMembros = 1, Pontos = 0};
tCap.team = tAdd;
@ -122,11 +161,11 @@ namespace api.Controllers
public async Task<IActionResult> ChangeName(TeamChangeName NameChange)
{
Team tEdit = await context.Teams.Include(t=>t.Cap).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);
if(cap == tEdit.Cap){
if(cap.QRcode == tEdit.CapQR){
tEdit.Nome = NameChange.nome;
}
@ -144,11 +183,11 @@ namespace api.Controllers
public async Task<IActionResult> DeleteTeam(TeamDelete DeleteData)
{
Team tEdit = await context.Teams.Include(t=>t.Cap).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);
if(cap == tEdit.Cap){
if(cap.QRcode == tEdit.CapQR){
context.Teams.Remove(tEdit);
cap.team = null;
context.Users.Update(cap);
@ -167,9 +206,9 @@ namespace api.Controllers
User rmMember = await context.Users.FirstOrDefaultAsync(u=>u.QRcode == MemberToRemove.UserToRemoveQR);
Team tEdit = await context.Teams.Include(t=>t.Cap).FirstOrDefaultAsync(t=>t.Id == MemberToRemove.TeamID);
Team tEdit = await context.Teams.FirstOrDefaultAsync(t=>t.Id == MemberToRemove.TeamID);
if(rmMember == tEdit.Cap){
if(rmMember.QRcode == tEdit.CapQR){
return StatusCode(403);
}

View File

@ -39,7 +39,7 @@ namespace api.Data
public async Task<IEnumerable<EventLoc>> GetEventLocs()
{
var rEventLocs = await _context.EventLocs.ToListAsync();
var rEventLocs = await _context.EventLocs.Include(a=>a.Img).ToListAsync();
return rEventLocs;
}

View File

@ -7,11 +7,5 @@ namespace api.Data
{
public interface ITeamsRepository
{
Task<IEnumerable<Team>> GetTeams();
Task<List<Team>> GetEventTeam(int id);
Task<Team> GetUserTeam(String QR);
}
}

View File

@ -16,32 +16,5 @@ namespace api.Data
public DataContext _context { get; }
public async Task<List<Team>> GetEventTeam(int id)
{
List<Team> allTeams = await _context.Teams.Include(a=>a.Cap).ToListAsync();
List<Team> rTeam = new List<Team>();
allTeams.ForEach(delegate(Team t){
if(t.EventId == id){
rTeam.Add(t);
}
});
return rTeam;
}
public async Task<Team> GetUserTeam(String QR)
{
var rTeam = (await _context.Users.FirstAsync(u=>u.QRcode == QR)).team;
return rTeam;
}
public async Task<IEnumerable<Team>> GetTeams()
{
var rTeams = await _context.Teams.Include(a=>a.Cap).ToListAsync();
return rTeams;
}
}
}

View File

@ -8,7 +8,7 @@ namespace api.Dtos
public class EventLocVisitedAdd
{
[Required]
public String USerQR{get;set;} //User ID
public String UserQR{get;set;} //User ID
[Required]
public int EventLocID{get;set;} //Loc id

17
api/Dtos/TeamToReturn.cs Normal file
View File

@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using api.Models;
namespace api.Dtos
{
public class TeamToReturn
{
public int Id{get;set;} //id
public int EventId{get;set;} //equipa para o evento ID
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 int Pontos {get;set;} //Postos da equipa
}
}

View File

@ -13,6 +13,7 @@ namespace api.Helpers
CreateMap<User, UserForDetailedDto>();
CreateMap<Photo,PhotosForDetailedDto>();
CreateMap<UserForUpdateDto,User>();
CreateMap<Team,TeamToReturn>();
}

View File

@ -9,8 +9,8 @@ using api.Data;
namespace api.Migrations
{
[DbContext(typeof(DataContext))]
[Migration("20190309183026_TeamsV2")]
partial class TeamsV2
[Migration("20190316174616_TeamsV3")]
partial class TeamsV3
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
@ -87,6 +87,30 @@ namespace api.Migrations
b.ToTable("AspNetUserTokens");
});
modelBuilder.Entity("api.Models.Cromos", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd();
b.Property<string>("DescLocked");
b.Property<string>("DescMostrar");
b.Property<string>("DescUnlocked");
b.Property<string>("Nome");
b.Property<string>("QRCode");
b.Property<int?>("imgId");
b.HasKey("Id");
b.HasIndex("imgId");
b.ToTable("Cromos");
});
modelBuilder.Entity("api.Models.Event", b =>
{
b.Property<int>("Id")
@ -243,7 +267,7 @@ namespace api.Migrations
b.Property<int>("Id")
.ValueGeneratedOnAdd();
b.Property<int?>("CapID");
b.Property<string>("CapQR");
b.Property<int>("EventId");
@ -255,8 +279,6 @@ namespace api.Migrations
b.HasKey("Id");
b.HasIndex("CapID");
b.ToTable("Teams");
});
@ -300,6 +322,8 @@ namespace api.Migrations
b.Property<string>("UserName")
.HasMaxLength(256);
b.Property<string>("cromos");
b.Property<int>("drinks");
b.Property<int>("food");
@ -377,6 +401,13 @@ namespace api.Migrations
.OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity("api.Models.Cromos", b =>
{
b.HasOne("api.Models.Photo", "img")
.WithMany()
.HasForeignKey("imgId");
});
modelBuilder.Entity("api.Models.EventLoc", b =>
{
b.HasOne("api.Models.Photo", "Img")
@ -418,13 +449,6 @@ namespace api.Migrations
.OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity("api.Models.Team", b =>
{
b.HasOne("api.Models.User", "Cap")
.WithMany()
.HasForeignKey("CapID");
});
modelBuilder.Entity("api.Models.User", b =>
{
b.HasOne("api.Models.Team", "team")

View File

@ -4,7 +4,7 @@ using Microsoft.EntityFrameworkCore.Migrations;
namespace api.Migrations
{
public partial class TeamsV2 : Migration
public partial class TeamsV3 : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
@ -53,6 +53,23 @@ namespace api.Migrations
table.PrimaryKey("PK_Products", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Teams",
columns: table => new
{
Id = table.Column<int>(nullable: false)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
EventId = table.Column<int>(nullable: false),
Nome = table.Column<string>(nullable: true),
CapQR = table.Column<string>(nullable: true),
NMembros = table.Column<int>(nullable: false),
Pontos = table.Column<int>(nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Teams", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Values",
columns: table => new
@ -88,21 +105,40 @@ namespace api.Migrations
});
migrationBuilder.CreateTable(
name: "AspNetUserRoles",
name: "AspNetUsers",
columns: table => new
{
UserId = table.Column<int>(nullable: false),
RoleId = table.Column<int>(nullable: false)
Id = table.Column<int>(nullable: false)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
UserName = table.Column<string>(maxLength: 256, nullable: true),
NormalizedUserName = table.Column<string>(maxLength: 256, nullable: true),
Email = table.Column<string>(maxLength: 256, nullable: true),
NormalizedEmail = table.Column<string>(maxLength: 256, nullable: true),
EmailConfirmed = table.Column<bool>(nullable: false),
PasswordHash = table.Column<string>(nullable: true),
SecurityStamp = table.Column<string>(nullable: true),
ConcurrencyStamp = table.Column<string>(nullable: true),
PhoneNumber = table.Column<string>(nullable: true),
PhoneNumberConfirmed = table.Column<bool>(nullable: false),
TwoFactorEnabled = table.Column<bool>(nullable: false),
LockoutEnd = table.Column<DateTimeOffset>(nullable: true),
LockoutEnabled = table.Column<bool>(nullable: false),
AccessFailedCount = table.Column<int>(nullable: false),
QRcode = table.Column<string>(nullable: true),
drinks = table.Column<int>(nullable: false),
food = table.Column<int>(nullable: false),
teamID = table.Column<int>(nullable: true),
cromos = table.Column<string>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_AspNetUserRoles", x => new { x.UserId, x.RoleId });
table.PrimaryKey("PK_AspNetUsers", x => x.Id);
table.ForeignKey(
name: "FK_AspNetUserRoles_AspNetRoles_RoleId",
column: x => x.RoleId,
principalTable: "AspNetRoles",
name: "FK_AspNetUsers_Teams_teamID",
column: x => x.teamID,
principalTable: "Teams",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateTable(
@ -118,6 +154,12 @@ namespace api.Migrations
constraints: table =>
{
table.PrimaryKey("PK_AspNetUserClaims", x => x.Id);
table.ForeignKey(
name: "FK_AspNetUserClaims_AspNetUsers_UserId",
column: x => x.UserId,
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
@ -132,6 +174,36 @@ namespace api.Migrations
constraints: table =>
{
table.PrimaryKey("PK_AspNetUserLogins", x => new { x.LoginProvider, x.ProviderKey });
table.ForeignKey(
name: "FK_AspNetUserLogins_AspNetUsers_UserId",
column: x => x.UserId,
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "AspNetUserRoles",
columns: table => new
{
UserId = table.Column<int>(nullable: false),
RoleId = table.Column<int>(nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_AspNetUserRoles", x => new { x.UserId, x.RoleId });
table.ForeignKey(
name: "FK_AspNetUserRoles_AspNetRoles_RoleId",
column: x => x.RoleId,
principalTable: "AspNetRoles",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_AspNetUserRoles_AspNetUsers_UserId",
column: x => x.UserId,
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
@ -146,6 +218,12 @@ namespace api.Migrations
constraints: table =>
{
table.PrimaryKey("PK_AspNetUserTokens", x => new { x.UserId, x.LoginProvider, x.Name });
table.ForeignKey(
name: "FK_AspNetUserTokens_AspNetUsers_UserId",
column: x => x.UserId,
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
@ -165,6 +243,18 @@ namespace api.Migrations
constraints: table =>
{
table.PrimaryKey("PK_Logs", x => x.Id);
table.ForeignKey(
name: "FK_Logs_AspNetUsers_UserId",
column: x => x.UserId,
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
table.ForeignKey(
name: "FK_Logs_AspNetUsers_UserId1",
column: x => x.UserId1,
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
table.ForeignKey(
name: "FK_Logs_Products_productId",
column: x => x.productId,
@ -188,6 +278,36 @@ namespace api.Migrations
constraints: table =>
{
table.PrimaryKey("PK_Photos", x => x.Id);
table.ForeignKey(
name: "FK_Photos_AspNetUsers_UserId",
column: x => x.UserId,
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "Cromos",
columns: table => new
{
Id = table.Column<int>(nullable: false)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
QRCode = table.Column<string>(nullable: true),
Nome = table.Column<string>(nullable: true),
DescLocked = table.Column<string>(nullable: true),
DescUnlocked = table.Column<string>(nullable: true),
DescMostrar = table.Column<string>(nullable: true),
imgId = table.Column<int>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Cromos", x => x.Id);
table.ForeignKey(
name: "FK_Cromos_Photos_imgId",
column: x => x.imgId,
principalTable: "Photos",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateTable(
@ -214,59 +334,6 @@ namespace api.Migrations
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateTable(
name: "Teams",
columns: table => new
{
Id = table.Column<int>(nullable: false)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
EventId = table.Column<int>(nullable: false),
Nome = table.Column<string>(nullable: true),
CapID = table.Column<int>(nullable: true),
NMembros = table.Column<int>(nullable: false),
Pontos = table.Column<int>(nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Teams", x => x.Id);
});
migrationBuilder.CreateTable(
name: "AspNetUsers",
columns: table => new
{
Id = table.Column<int>(nullable: false)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
UserName = table.Column<string>(maxLength: 256, nullable: true),
NormalizedUserName = table.Column<string>(maxLength: 256, nullable: true),
Email = table.Column<string>(maxLength: 256, nullable: true),
NormalizedEmail = table.Column<string>(maxLength: 256, nullable: true),
EmailConfirmed = table.Column<bool>(nullable: false),
PasswordHash = table.Column<string>(nullable: true),
SecurityStamp = table.Column<string>(nullable: true),
ConcurrencyStamp = table.Column<string>(nullable: true),
PhoneNumber = table.Column<string>(nullable: true),
PhoneNumberConfirmed = table.Column<bool>(nullable: false),
TwoFactorEnabled = table.Column<bool>(nullable: false),
LockoutEnd = table.Column<DateTimeOffset>(nullable: true),
LockoutEnabled = table.Column<bool>(nullable: false),
AccessFailedCount = table.Column<int>(nullable: false),
QRcode = table.Column<string>(nullable: true),
drinks = table.Column<int>(nullable: false),
food = table.Column<int>(nullable: false),
teamID = table.Column<int>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_AspNetUsers", x => x.Id);
table.ForeignKey(
name: "FK_AspNetUsers_Teams_teamID",
column: x => x.teamID,
principalTable: "Teams",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateTable(
name: "EventLocsVisited",
columns: table => new
@ -336,6 +403,11 @@ namespace api.Migrations
table: "AspNetUsers",
column: "teamID");
migrationBuilder.CreateIndex(
name: "IX_Cromos_imgId",
table: "Cromos",
column: "imgId");
migrationBuilder.CreateIndex(
name: "IX_EventLocs_ImgId",
table: "EventLocs",
@ -370,83 +442,10 @@ namespace api.Migrations
name: "IX_Photos_UserId",
table: "Photos",
column: "UserId");
migrationBuilder.CreateIndex(
name: "IX_Teams_CapID",
table: "Teams",
column: "CapID");
migrationBuilder.AddForeignKey(
name: "FK_AspNetUserRoles_AspNetUsers_UserId",
table: "AspNetUserRoles",
column: "UserId",
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_AspNetUserClaims_AspNetUsers_UserId",
table: "AspNetUserClaims",
column: "UserId",
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_AspNetUserLogins_AspNetUsers_UserId",
table: "AspNetUserLogins",
column: "UserId",
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_AspNetUserTokens_AspNetUsers_UserId",
table: "AspNetUserTokens",
column: "UserId",
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_Logs_AspNetUsers_UserId",
table: "Logs",
column: "UserId",
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
migrationBuilder.AddForeignKey(
name: "FK_Logs_AspNetUsers_UserId1",
table: "Logs",
column: "UserId1",
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
migrationBuilder.AddForeignKey(
name: "FK_Photos_AspNetUsers_UserId",
table: "Photos",
column: "UserId",
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_Teams_AspNetUsers_CapID",
table: "Teams",
column: "CapID",
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_Teams_AspNetUsers_CapID",
table: "Teams");
migrationBuilder.DropTable(
name: "AspNetRoleClaims");
@ -462,6 +461,9 @@ namespace api.Migrations
migrationBuilder.DropTable(
name: "AspNetUserTokens");
migrationBuilder.DropTable(
name: "Cromos");
migrationBuilder.DropTable(
name: "EventLocsVisited");

View File

@ -85,6 +85,30 @@ namespace api.Migrations
b.ToTable("AspNetUserTokens");
});
modelBuilder.Entity("api.Models.Cromos", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd();
b.Property<string>("DescLocked");
b.Property<string>("DescMostrar");
b.Property<string>("DescUnlocked");
b.Property<string>("Nome");
b.Property<string>("QRCode");
b.Property<int?>("imgId");
b.HasKey("Id");
b.HasIndex("imgId");
b.ToTable("Cromos");
});
modelBuilder.Entity("api.Models.Event", b =>
{
b.Property<int>("Id")
@ -241,7 +265,7 @@ namespace api.Migrations
b.Property<int>("Id")
.ValueGeneratedOnAdd();
b.Property<int?>("CapID");
b.Property<string>("CapQR");
b.Property<int>("EventId");
@ -253,8 +277,6 @@ namespace api.Migrations
b.HasKey("Id");
b.HasIndex("CapID");
b.ToTable("Teams");
});
@ -298,6 +320,8 @@ namespace api.Migrations
b.Property<string>("UserName")
.HasMaxLength(256);
b.Property<string>("cromos");
b.Property<int>("drinks");
b.Property<int>("food");
@ -375,6 +399,13 @@ namespace api.Migrations
.OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity("api.Models.Cromos", b =>
{
b.HasOne("api.Models.Photo", "img")
.WithMany()
.HasForeignKey("imgId");
});
modelBuilder.Entity("api.Models.EventLoc", b =>
{
b.HasOne("api.Models.Photo", "Img")
@ -416,13 +447,6 @@ namespace api.Migrations
.OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity("api.Models.Team", b =>
{
b.HasOne("api.Models.User", "Cap")
.WithMany()
.HasForeignKey("CapID");
});
modelBuilder.Entity("api.Models.User", b =>
{
b.HasOne("api.Models.Team", "team")

View File

@ -10,9 +10,7 @@ namespace api.Models
public int Id{get;set;} //id
public int EventId{get;set;} //equipa para o evento ID
public string Nome{get;set;} //Nome da equipa
[ForeignKey("CapID")]
public User Cap{get;set;} //Capitao da equipa
public string CapQR{get;set;} //Capitao da equipa
public int NMembros {get;set;} //Numero de Membros na equipa
public int Pontos {get;set;} //Postos da equipa
}

View File

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

View File

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