using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using HyperCube.Models;

// For more information on enabling Web API for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860

namespace HyperCube.Controllers
{
    [Route("api/[controller]")]
    [ApiController]
    public class ValuesController : ControllerBase
    {
        // GET: api/<ValuesController>
        [HttpGet]
        public IEnumerable<string> Get()
        {
            return new string[] {};
        }

        // GET api/<ValuesController>/5
        [HttpGet("{id}/{email}")]
        public async Task<string> Get(int id, string email)
        {
            var acc = AccountModel.FindByMail(email);
            string transactionId = $"not found: {id} {email}";
            var article = ArticleModel.Find(id);
            if (article != null && acc != null)
            {
                var bc = await acc.GetSelectedBlockChain();
                transactionId = await SmartContract.Verify(acc, article, bc);
            }
            return transactionId;
        }

        // POST api/<ValuesController>
        [HttpPost]
        public void Post([FromBody] string value)
        {
        }

        // PUT api/<ValuesController>/5
        [HttpPut("{id}")]
        public void Put(int id, [FromBody] string value)
        {
        }

        // DELETE api/<ValuesController>/5
        [HttpDelete("{id}")]
        public void Delete(int id)
        {
        }
    }
}
