MICHELE: CHIAMATE/ IMPIANTI
This commit is contained in:
parent
4234c6b4f1
commit
16539d257c
@ -1,4 +1,5 @@
|
|||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using Microsoft.AspNetCore.Mvc.Rendering;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
@ -82,6 +83,7 @@ namespace VirtualTask.Controllers
|
|||||||
|
|
||||||
public IActionResult Create()
|
public IActionResult Create()
|
||||||
{
|
{
|
||||||
|
ViewBag.AllStockList = LoadStockItems();
|
||||||
return View();
|
return View();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -115,7 +117,7 @@ namespace VirtualTask.Controllers
|
|||||||
return RedirectToAction("Error");
|
return RedirectToAction("Error");
|
||||||
}
|
}
|
||||||
|
|
||||||
return View();
|
//return View();
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion CREATE
|
#endregion CREATE
|
||||||
@ -129,7 +131,7 @@ namespace VirtualTask.Controllers
|
|||||||
token = helper.GetStringValue("tok");
|
token = helper.GetStringValue("tok");
|
||||||
|
|
||||||
apiUrl = helper.GetStringValue("apiUrl");
|
apiUrl = helper.GetStringValue("apiUrl");
|
||||||
urlBase = apiUrl + "chiamate";
|
urlBase = apiUrl + "chiamateList";
|
||||||
urlBase = urlBase + "?token=" + token;
|
urlBase = urlBase + "?token=" + token;
|
||||||
Uri baseAddress = new Uri(urlBase);
|
Uri baseAddress = new Uri(urlBase);
|
||||||
client = new HttpClient();
|
client = new HttpClient();
|
||||||
@ -168,7 +170,7 @@ namespace VirtualTask.Controllers
|
|||||||
token = helper.GetStringValue("tok");
|
token = helper.GetStringValue("tok");
|
||||||
|
|
||||||
apiUrl = helper.GetStringValue("apiUrl");
|
apiUrl = helper.GetStringValue("apiUrl");
|
||||||
urlBase = apiUrl + "chiamate";
|
urlBase = apiUrl + "chiamateList";
|
||||||
urlBase = urlBase + "?token=" + token;
|
urlBase = urlBase + "?token=" + token;
|
||||||
Uri baseAddress = new Uri(urlBase);
|
Uri baseAddress = new Uri(urlBase);
|
||||||
client = new HttpClient();
|
client = new HttpClient();
|
||||||
@ -193,6 +195,7 @@ namespace VirtualTask.Controllers
|
|||||||
return RedirectToAction("Error");
|
return RedirectToAction("Error");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ViewBag.AllStockList = LoadStockItems();
|
||||||
return View(chiamata);
|
return View(chiamata);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -244,7 +247,7 @@ namespace VirtualTask.Controllers
|
|||||||
token = helper.GetStringValue("tok");
|
token = helper.GetStringValue("tok");
|
||||||
|
|
||||||
apiUrl = helper.GetStringValue("apiUrl");
|
apiUrl = helper.GetStringValue("apiUrl");
|
||||||
urlBase = apiUrl + "chiamate";
|
urlBase = apiUrl + "chiamateList";
|
||||||
urlBase = urlBase + "?token=" + token;
|
urlBase = urlBase + "?token=" + token;
|
||||||
Uri baseAddress = new Uri(urlBase);
|
Uri baseAddress = new Uri(urlBase);
|
||||||
client = new HttpClient();
|
client = new HttpClient();
|
||||||
@ -302,6 +305,34 @@ namespace VirtualTask.Controllers
|
|||||||
}
|
}
|
||||||
#endregion DELETE
|
#endregion DELETE
|
||||||
|
|
||||||
|
private List<SelectListItem> LoadStockItems()
|
||||||
|
{
|
||||||
|
SessionHelper helper = new SessionHelper(this);
|
||||||
|
token = helper.GetStringValue("tok");
|
||||||
|
apiUrl = helper.GetStringValue("apiUrl");
|
||||||
|
urlBase = apiUrl + "impiantiList";
|
||||||
|
urlBase = urlBase + "?token=" + token;
|
||||||
|
Uri baseAddress = new Uri(urlBase);
|
||||||
|
client = new HttpClient();
|
||||||
|
client.BaseAddress = baseAddress;
|
||||||
|
List<SelectListItem> selectItems = new List<SelectListItem>();
|
||||||
|
List<Impianto> modelList = new List<Impianto>();
|
||||||
|
HttpResponseMessage response = client.GetAsync(baseAddress).Result;
|
||||||
|
if (response.IsSuccessStatusCode)
|
||||||
|
{
|
||||||
|
string data = response.Content.ReadAsStringAsync().Result;
|
||||||
|
modelList = JsonConvert.DeserializeObject<List<Impianto>>(data);
|
||||||
|
foreach (var role in modelList)
|
||||||
|
{
|
||||||
|
SelectListItem listItem = new SelectListItem();
|
||||||
|
listItem.Value = role.imcodimp;
|
||||||
|
listItem.Text = role.imdescri;
|
||||||
|
selectItems.Add(listItem);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return selectItems;
|
||||||
|
}
|
||||||
|
|
||||||
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
|
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
|
||||||
public IActionResult Error()
|
public IActionResult Error()
|
||||||
{
|
{
|
||||||
|
|||||||
@ -230,7 +230,7 @@ namespace VirtualTask.Controllers
|
|||||||
return RedirectToAction("Error");
|
return RedirectToAction("Error");
|
||||||
}
|
}
|
||||||
|
|
||||||
//return View(model);
|
return View(model);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion EDIT
|
#endregion EDIT
|
||||||
|
|||||||
@ -70,7 +70,8 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label asp-for="chcodimp" class="control-label"></label>
|
<label asp-for="chcodimp" class="control-label"></label>
|
||||||
<input asp-for="chcodimp" class="form-control" />
|
@*<input asp-for="chcodimp" class="form-control" />*@
|
||||||
|
@Html.DropDownListFor(x => x.chcodimp,(IEnumerable<SelectListItem>)ViewBag.AllStockList, new {@class = "form-control"})
|
||||||
<span asp-validation-for="chcodimp" class="text-danger"></span>
|
<span asp-validation-for="chcodimp" class="text-danger"></span>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
@ -310,6 +311,11 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<script type="text/javascript">
|
||||||
|
$(function () {
|
||||||
|
$("#chcodimp").select2();
|
||||||
|
});
|
||||||
|
</script>
|
||||||
<div>
|
<div>
|
||||||
<a asp-action="Index">Back to List</a>
|
<a asp-action="Index">Back to List</a>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user