SoftwayWeb/Controllers/ConsegneController.cs
2024-07-08 09:15:04 +02:00

60 lines
2.3 KiB
C#

using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json;
using SoftwayWeb.Models;
using X.PagedList;
namespace SoftwayWeb.Controllers
{
public class ConsegneController : Controller
{
string apiUrl = string.Empty;
string urlBase = string.Empty;
string token = string.Empty;
string errMes = string.Empty;
private readonly IConfiguration _configuration;
HttpClient client;
SessionHelper helper;
public ConsegneController(IConfiguration configuration)
{
_configuration = configuration;
client = new HttpClient();
var key = _configuration["ApplicationInsights:rootUrlApi"];
apiUrl = key;
}
public IActionResult Index(string id/*, string? codAutista, DateTime dataGiro, string? codMezzo*/)
{
//helper = new SessionHelper(this);
//token = helper.GetStringValue("tok");
//urlBase = apiUrl + "Giri/listaDestinazioniByAutistaDataMezzo";
////dataGiro = dataGiro.ToUniversalTime();
////urlBase = urlBase + "autista=" + giro.CodAutista + "datGiro=" + giro.DataGiro;
//urlBase = urlBase + "?autista=" + codAutista.Trim() + "&dataGiro=2023-05-30T00%3A00%3A00.000Z" + "&mezzo=" + codMezzo /*+ dataGiro*/;
//Uri baseAddress = new Uri(urlBase);
//client = new HttpClient();
//client.BaseAddress = baseAddress;
//List<Destinazioni_Out.ConsegnaFatta> modelList = new List<Destinazioni_Out.ConsegnaFatta>();
//HttpResponseMessage response = client.GetAsync(baseAddress).Result;
//if (response.IsSuccessStatusCode)
//{
// string dato = response.Content.ReadAsStringAsync().Result;
// modelList = JsonConvert.DeserializeObject<List<Destinazioni_Out.ConsegnaFatta>>(dato);
// modelList = modelList.Where(x => x.consFattaSerial == id).ToList();
// var shortList = modelList.ToPagedList();
// return View(modelList/*shortList*/);
//}
//else
//{
// errMes = response.Content.ReadAsStringAsync().Result;
// helper.SetStringValue("errMsg", errMes);
// return RedirectToAction("Error");
//}
return View();
}
}
}