cromos pontuação
This commit is contained in:
parent
92a9fb8a2c
commit
bd37518d76
|
@ -30,8 +30,9 @@ namespace api.Controllers
|
|||
// GET api/cromos/QR
|
||||
// GET cromos do user QR
|
||||
[HttpGet("{QR}")]
|
||||
public async Task<List<Cromos>> GetCromos(string QR)
|
||||
public async Task<IActionResult> GetCromos(string QR)
|
||||
{
|
||||
int soma=0;
|
||||
var usr = await context.Users.FirstOrDefaultAsync(u=>u.QRcode == QR);
|
||||
string[] usrCromos = usr.cromos.Substring(1).Split(",");
|
||||
Console.WriteLine(usrCromos[0]);
|
||||
|
@ -44,7 +45,7 @@ namespace api.Controllers
|
|||
for(int i=0;i<usrCromos.Length;i++){
|
||||
|
||||
if(Int32.Parse(usrCromos[i])==c.Id){
|
||||
|
||||
soma+=c.pontos;
|
||||
Cromos toAdd = new Cromos{Id = c.Id,Nome=c.Nome,DescMostrar=c.DescUnlocked,QRCode=c.QRCode,img=c.img, unlocked=true, websiteCromo=c.websiteCromo,pontos=c.pontos, logo=c.logo};
|
||||
rList.Add(toAdd);
|
||||
|
||||
|
@ -55,7 +56,11 @@ namespace api.Controllers
|
|||
}
|
||||
}
|
||||
});
|
||||
return rList;
|
||||
|
||||
cromosToReturn a= new cromosToReturn();
|
||||
a.cromos= rList;
|
||||
a.pontuacao=soma;
|
||||
return Ok(a);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using api.Models;
|
||||
|
||||
namespace api.Dtos
|
||||
{
|
||||
public class cromosToReturn
|
||||
{
|
||||
[Required]
|
||||
public List<Cromos> cromos{get;set;} //equipa id
|
||||
|
||||
[Required]
|
||||
public Int pontuacao{get;set;} //novo membro
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue