using System; using System.Collections.Generic; using System.Linq; using System.Net.Http; using System.Net.Http.Headers; using System.Net.Http.Formatting; using System.Threading.Tasks; using Microsoft.AspNetCore.Mvc; using Syncfusion.EJ2; using BWPMModels; using System.Collections; using Syncfusion.EJ2.Base; using sf1.Models; using Microsoft.Extensions.Configuration; using Newtonsoft.Json; using System.Reflection; namespace sf1.Controllers { public partial class UserController : Controller { private const string URL = "http://localhost/CoreWebAPI1/api/"; public IActionResult Index() { return View(); } [HttpPost] public IActionResult UrlDatasource([FromBody] DataManagerRequest dm) { Helper.HttpClientHelper httpcli = new Helper.HttpClientHelper(); httpcli.CallService("user", "", "GET",null); if (httpcli.Results.resultstatus != true) { return View(); } List users = JsonConvert.DeserializeObject>(httpcli.Results.daten); ViewBag.DataSource = users; IEnumerable DataSource = users; DataOperations operation = new DataOperations(); if (dm.Search != null && dm.Search.Count > 0) { DataSource = operation.PerformSearching(DataSource, dm.Search); //Search } if (dm.Sorted != null && dm.Sorted.Count > 0) //Sorting { DataSource = operation.PerformSorting(DataSource, dm.Sorted); } if (dm.Where != null && dm.Where.Count > 0) { DataSource = operation.PerformFiltering(DataSource, dm.Where, dm.Where[0].Operator); //Filtering } int count = DataSource.Cast().Count(); if (dm.Skip != 0) { DataSource = operation.PerformSkip(DataSource, dm.Skip); //Paging } if (dm.Take != 0) { DataSource = operation.PerformTake(DataSource, dm.Take); } return dm.RequiresCounts ? Json(new { result = DataSource, count = count }) : Json(DataSource); } public ActionResult Update([FromBody] ICRUDModel value) { Helper.HttpClientHelper httpcli = new Helper.HttpClientHelper(); User u = new User(); u = value.value; httpcli.CallService("user",u.ID.ToString(), "PUT", value.value); if (httpcli.Results.resultstatuscode !="OK") { return View(); } return Json(value.value); } public ActionResult Insert([FromBody] ICRUDModel value) { Helper.HttpClientHelper httpcli = new Helper.HttpClientHelper(); User u = new User(); u = value.value; u.Teststring = "hallo"; u.aktiv = true; httpcli.CallService("user", "", "POST", u); if (httpcli.Results.resultstatuscode != "OK") { return View(); } return Json(value.value); } public ActionResult Remove([FromBody] CRUDModel value) { Helper.HttpClientHelper httpcli = new Helper.HttpClientHelper(); httpcli.CallService("user", value.Key.ToString(), "DELETE", null); if (httpcli.Results.resultstatuscode != "OK") { return View(); } return Json(value); } } }