You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
112 lines
3.5 KiB
112 lines
3.5 KiB
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 Microsoft.Extensions.Configuration;
|
|
using Newtonsoft.Json;
|
|
using System.Reflection;
|
|
using App.Models;
|
|
|
|
namespace App.Controllers
|
|
{
|
|
public partial class UserController : Controller
|
|
{
|
|
|
|
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<User> users = JsonConvert.DeserializeObject<List<User>>(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<User>().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<User> 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<User> value)
|
|
{
|
|
Helper.HttpClientHelper httpcli = new Helper.HttpClientHelper();
|
|
User u = new User();
|
|
u = value.value;
|
|
httpcli.CallService("user", "", "POST", u);
|
|
if (httpcli.Results.resultstatuscode != "OK")
|
|
{
|
|
return View();
|
|
}
|
|
return Json(value.value);
|
|
}
|
|
|
|
public ActionResult Remove([FromBody] CRUDModel<User> 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);
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
}
|