cromos pontuação

This commit is contained in:
henrydays 2019-03-19 01:25:54 +00:00
parent 92a9fb8a2c
commit bd37518d76
2 changed files with 24 additions and 3 deletions

View File

@ -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);
}
}

View File

@ -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
}
}