using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using DevXCore.Models;
using DevExtreme.AspNet.Data;
using DevExtreme.AspNet.Mvc;
using DevXCore.Models.DBContext;
using MvcContrib.UI.DataList;
using System.Data;
using Newtonsoft.Json;
namespace DevXCore.Controllers.Api
{
[Route("api/[controller]")]
[ApiController]
public class apiDemoController : ControllerBase
{
#region Controller Init
private readonly ApplicationDbContext _dbContext;
public apiDemoController(ApplicationDbContext
dbContext)
{
//----< Init: Controller >----
_dbContext = dbContext;
//----</ Init: Controller >----
}
#endregion
[HttpGet("getGridData")]
public object getGridData(DataSourceLoadOptions
loadOptions, string filterGridParameters)
{
///-------------< getDataGrid() >-------------
if (filterGridParameters != null)
{
var orgaIdList =
filterGridParameters.Split(","); //.Select(Int32.Parse).ToList();
Console.Write(orgaIdList);
}
//--< Get Linq.Query >--
//DataView view = new DataView();
DataTable dtTable = new DataTable(); // view.ToTable(false,< string array =
"" >);
dtTable.Columns.Add("IDKey", typeof(String));
dtTable.Columns.Add("description", typeof(String));
dtTable.Columns.Add("col_1", typeof(String)); //Double
dtTable.Columns.Add("col_2", typeof(String)); //Double
dtTable.Columns.Add("col_3", typeof(String)); //Double
DataRow row = dtTable.Rows.Add();
row["IDKey"] = "A";
row["description"] = "format 0->0 2.12->2,12 3.123->3,12";
row["col_1"] = 0;
row["col_2"] = 2.12;
row["col_3"] = 3.123;
row = dtTable.Rows.Add();
row["IDKey"] = "B";
row["description"] = "format 0->0 2.12->2,12 3.123->3,12";
row["col_1"] = 0;
row["col_2"] = 2.12;
row["col_3"] = 3.123;
row = dtTable.Rows.Add();
row["IDKey"] = "C";
row["col_1"] = 123456;
row["col_2"] = 333333.789;
row["col_3"] = 555555.12345;
List<DataRow> dataList =
dtTable.Select().ToList();
//----< fill Data_to_View >----
//---< @Loop: Rows >---
//----</ fill Data_to_View >----
return
JsonConvert.SerializeObject(dtTable) ;
///-------------</ getDataGrid()
>-------------
}
[HttpPut("UpdateGridCell")]
public ActionResult
UpdateGridCell([FromForm] Dictionary<string,string> cell)
{
//-------------< UpdateGridRow()
>-------------
var sKey = cell["key"]; //ID=A
var sCell_Column_Value = cell["values"]; //{"..":".."}
sCell_Column_Value =
sCell_Column_Value.Substring(1,sCell_Column_Value.Length-2); //"..":".."
string[] arrCell_Column_Value =
sCell_Column_Value.Split(':');
string sColumn_Name = arrCell_Column_Value[0]; //"col_1"
string sCell_Value =
arrCell_Column_Value[1]; //"123,45"
return Ok();
//-------------</
UpdateGridRow() >-------------
}
}
}
|