diff --git a/api/Controllers/CromosController.cs b/api/Controllers/CromosController.cs index 6e479c8e..cc63e2ff 100644 --- a/api/Controllers/CromosController.cs +++ b/api/Controllers/CromosController.cs @@ -29,11 +29,12 @@ namespace api.Controllers // GET api/cromos/QR // GET cromos do user QR - [HttpGet] + [HttpGet("{QR}")] public async Task> GetCromos(string QR) { var usr = await context.Users.FirstOrDefaultAsync(u=>u.QRcode == QR); - var usrCromos = usr.cromos.Split(","); + string[] usrCromos = usr.cromos.Substring(1).Split(","); + Console.WriteLine(usrCromos[0]); var allCromos = await context.Cromos.ToListAsync(); List rList = new List(); diff --git a/api/Controllers/EventLocsController.cs b/api/Controllers/EventLocsController.cs index fa3345e8..65a8e4de 100644 --- a/api/Controllers/EventLocsController.cs +++ b/api/Controllers/EventLocsController.cs @@ -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 GetEventLocEvent(int id) { diff --git a/api/Controllers/EventLocsVisitedController.cs b/api/Controllers/EventLocsVisitedController.cs index 2f810294..b91b2fff 100644 --- a/api/Controllers/EventLocsVisitedController.cs +++ b/api/Controllers/EventLocsVisitedController.cs @@ -67,7 +67,7 @@ namespace api.Controllers public async Task 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); diff --git a/api/Controllers/ScanController.cs b/api/Controllers/ScanController.cs index 552cea20..d05d40b2 100644 --- a/api/Controllers/ScanController.cs +++ b/api/Controllers/ScanController.cs @@ -41,7 +41,9 @@ namespace api.Controllers 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{ @@ -59,7 +61,7 @@ namespace api.Controllers return toReturn; } - return toReturn; + //return toReturn; } } diff --git a/api/Controllers/TeamsController.cs b/api/Controllers/TeamsController.cs index a7274ace..a15c495b 100644 --- a/api/Controllers/TeamsController.cs +++ b/api/Controllers/TeamsController.cs @@ -36,28 +36,67 @@ namespace api.Controllers // GET api/teams // GET all teams [HttpGet] - public async Task GetTeams() + public async Task> GetTeams() { - var Teams = await _repo.GetTeams(); - return Ok(Teams); + List allTeams = await context.Teams.ToListAsync(); + List rTeams = new List(); + + 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 GetTeamsEvent(int id) + public async Task> GetTeamsEvent(int id) { - var Teams = await _repo.GetEventTeam(id); - return Ok(Teams); + List allTeams = await context.Teams.ToListAsync(); + List rTeam = new List(); + 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 GetTeamsUser(String QR) + public async Task 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 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 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 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 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); } diff --git a/api/Data/EventLocsRepository.cs b/api/Data/EventLocsRepository.cs index c4b22884..3644ebbd 100644 --- a/api/Data/EventLocsRepository.cs +++ b/api/Data/EventLocsRepository.cs @@ -39,7 +39,7 @@ namespace api.Data public async Task> GetEventLocs() { - var rEventLocs = await _context.EventLocs.ToListAsync(); + var rEventLocs = await _context.EventLocs.Include(a=>a.Img).ToListAsync(); return rEventLocs; } diff --git a/api/Data/ITeamsRepository.cs b/api/Data/ITeamsRepository.cs index ac5a220d..78f7f752 100644 --- a/api/Data/ITeamsRepository.cs +++ b/api/Data/ITeamsRepository.cs @@ -7,11 +7,5 @@ namespace api.Data { public interface ITeamsRepository { - - Task> GetTeams(); - Task> GetEventTeam(int id); - Task GetUserTeam(String QR); - - } } \ No newline at end of file diff --git a/api/Data/TeamsReposiroty.cs b/api/Data/TeamsReposiroty.cs index 0a0e3544..ceb37803 100644 --- a/api/Data/TeamsReposiroty.cs +++ b/api/Data/TeamsReposiroty.cs @@ -16,32 +16,5 @@ namespace api.Data public DataContext _context { get; } - public async Task> GetEventTeam(int id) - { - List allTeams = await _context.Teams.Include(a=>a.Cap).ToListAsync(); - List rTeam = new List(); - allTeams.ForEach(delegate(Team t){ - if(t.EventId == id){ - rTeam.Add(t); - } - }); - - return rTeam; - } - - public async Task GetUserTeam(String QR) - { - var rTeam = (await _context.Users.FirstAsync(u=>u.QRcode == QR)).team; - - return rTeam; - } - - public async Task> GetTeams() - { - var rTeams = await _context.Teams.Include(a=>a.Cap).ToListAsync(); - - return rTeams; - } - } } \ No newline at end of file diff --git a/api/Dtos/EventLocVisitedAdd.cs b/api/Dtos/EventLocVisitedAdd.cs index 87edbdc9..8c8d1e2a 100644 --- a/api/Dtos/EventLocVisitedAdd.cs +++ b/api/Dtos/EventLocVisitedAdd.cs @@ -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 diff --git a/api/Dtos/TeamToReturn.cs b/api/Dtos/TeamToReturn.cs new file mode 100644 index 00000000..cd0daf83 --- /dev/null +++ b/api/Dtos/TeamToReturn.cs @@ -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 + } +} \ No newline at end of file diff --git a/api/Helpers/AutoMapperProfiles.cs b/api/Helpers/AutoMapperProfiles.cs index acaaffc6..3cb7d535 100755 --- a/api/Helpers/AutoMapperProfiles.cs +++ b/api/Helpers/AutoMapperProfiles.cs @@ -13,6 +13,7 @@ namespace api.Helpers CreateMap(); CreateMap(); CreateMap(); + CreateMap(); } diff --git a/api/Migrations/20190316162716_cromos.Designer.cs b/api/Migrations/20190316174616_TeamsV3.Designer.cs similarity index 97% rename from api/Migrations/20190316162716_cromos.Designer.cs rename to api/Migrations/20190316174616_TeamsV3.Designer.cs index d41ea209..c1360124 100644 --- a/api/Migrations/20190316162716_cromos.Designer.cs +++ b/api/Migrations/20190316174616_TeamsV3.Designer.cs @@ -9,8 +9,8 @@ using api.Data; namespace api.Migrations { [DbContext(typeof(DataContext))] - [Migration("20190316162716_cromos")] - partial class cromos + [Migration("20190316174616_TeamsV3")] + partial class TeamsV3 { protected override void BuildTargetModel(ModelBuilder modelBuilder) { @@ -267,7 +267,7 @@ namespace api.Migrations b.Property("Id") .ValueGeneratedOnAdd(); - b.Property("CapID"); + b.Property("CapQR"); b.Property("EventId"); @@ -279,8 +279,6 @@ namespace api.Migrations b.HasKey("Id"); - b.HasIndex("CapID"); - b.ToTable("Teams"); }); @@ -451,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") diff --git a/api/Migrations/20190316162716_cromos.cs b/api/Migrations/20190316174616_TeamsV3.cs similarity index 86% rename from api/Migrations/20190316162716_cromos.cs rename to api/Migrations/20190316174616_TeamsV3.cs index 7698353a..c83741d5 100644 --- a/api/Migrations/20190316162716_cromos.cs +++ b/api/Migrations/20190316174616_TeamsV3.cs @@ -4,7 +4,7 @@ using Microsoft.EntityFrameworkCore.Migrations; namespace api.Migrations { - public partial class cromos : 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(nullable: false) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), + EventId = table.Column(nullable: false), + Nome = table.Column(nullable: true), + CapQR = table.Column(nullable: true), + NMembros = table.Column(nullable: false), + Pontos = table.Column(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(nullable: false), - RoleId = table.Column(nullable: false) + Id = table.Column(nullable: false) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), + UserName = table.Column(maxLength: 256, nullable: true), + NormalizedUserName = table.Column(maxLength: 256, nullable: true), + Email = table.Column(maxLength: 256, nullable: true), + NormalizedEmail = table.Column(maxLength: 256, nullable: true), + EmailConfirmed = table.Column(nullable: false), + PasswordHash = table.Column(nullable: true), + SecurityStamp = table.Column(nullable: true), + ConcurrencyStamp = table.Column(nullable: true), + PhoneNumber = table.Column(nullable: true), + PhoneNumberConfirmed = table.Column(nullable: false), + TwoFactorEnabled = table.Column(nullable: false), + LockoutEnd = table.Column(nullable: true), + LockoutEnabled = table.Column(nullable: false), + AccessFailedCount = table.Column(nullable: false), + QRcode = table.Column(nullable: true), + drinks = table.Column(nullable: false), + food = table.Column(nullable: false), + teamID = table.Column(nullable: true), + cromos = table.Column(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(nullable: false), + RoleId = table.Column(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,12 @@ 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( @@ -238,60 +334,6 @@ namespace api.Migrations onDelete: ReferentialAction.Restrict); }); - migrationBuilder.CreateTable( - name: "Teams", - columns: table => new - { - Id = table.Column(nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - EventId = table.Column(nullable: false), - Nome = table.Column(nullable: true), - CapID = table.Column(nullable: true), - NMembros = table.Column(nullable: false), - Pontos = table.Column(nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_Teams", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "AspNetUsers", - columns: table => new - { - Id = table.Column(nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - UserName = table.Column(maxLength: 256, nullable: true), - NormalizedUserName = table.Column(maxLength: 256, nullable: true), - Email = table.Column(maxLength: 256, nullable: true), - NormalizedEmail = table.Column(maxLength: 256, nullable: true), - EmailConfirmed = table.Column(nullable: false), - PasswordHash = table.Column(nullable: true), - SecurityStamp = table.Column(nullable: true), - ConcurrencyStamp = table.Column(nullable: true), - PhoneNumber = table.Column(nullable: true), - PhoneNumberConfirmed = table.Column(nullable: false), - TwoFactorEnabled = table.Column(nullable: false), - LockoutEnd = table.Column(nullable: true), - LockoutEnabled = table.Column(nullable: false), - AccessFailedCount = table.Column(nullable: false), - QRcode = table.Column(nullable: true), - drinks = table.Column(nullable: false), - food = table.Column(nullable: false), - teamID = table.Column(nullable: true), - cromos = table.Column(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 @@ -400,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"); diff --git a/api/Migrations/DataContextModelSnapshot.cs b/api/Migrations/DataContextModelSnapshot.cs index c727da13..49260cac 100644 --- a/api/Migrations/DataContextModelSnapshot.cs +++ b/api/Migrations/DataContextModelSnapshot.cs @@ -265,7 +265,7 @@ namespace api.Migrations b.Property("Id") .ValueGeneratedOnAdd(); - b.Property("CapID"); + b.Property("CapQR"); b.Property("EventId"); @@ -277,8 +277,6 @@ namespace api.Migrations b.HasKey("Id"); - b.HasIndex("CapID"); - b.ToTable("Teams"); }); @@ -449,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") diff --git a/api/Models/Team.cs b/api/Models/Team.cs index b70deb1e..4f1ab4b6 100755 --- a/api/Models/Team.cs +++ b/api/Models/Team.cs @@ -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 }