using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using HcUtility.Core;
using Newtonsoft.Json;
using DSWeb.MvcShipping.Helper;
namespace DSWeb.Areas.CommMng.Models
{
///
///
///
///
[JsonObject]
public class DatasetSort : ModelObjectBillHead
{
private string _property = String.Empty;
private string _direction = String.Empty;
[ModelDB]
public string property
{
get { return _property; }
set { _property = value; }
}
[ModelDB]
public string direction
{
get { return _direction; }
set { _direction = value; }
}
public static string Getsortstring(string jsonsort)
{
var result = "";
if (!string.IsNullOrEmpty(jsonsort))
{
try
{
var bodyList = DSWeb.MvcShipping.Helper.JsonConvert.Deserialize>(jsonsort);
if (bodyList != null)
{
foreach (var enumValue in bodyList)
{
if (result == "")
result = result + enumValue.property + " " + enumValue.direction;
else
result = result + "," + enumValue.property + " " + enumValue.direction;
}
}
}
catch
{
result = jsonsort;
}
return result;
//string tempSearch = jsonsort;
//var sorts = new DatasetSort();
//tempSearch = tempSearch.Replace("{", "");
//tempSearch = tempSearch.Replace("}", "");
//tempSearch = tempSearch.Replace("[", "");
//tempSearch = tempSearch.Replace("]", "");
//string[] searchArg = tempSearch.Split(new char[] { ',' });
//for (int i = 0; i < searchArg.Length; i++)
//{
// string[] strArg = searchArg[i].Split(new char[] { ':' });
// if (strArg.Count() > 1)
// {
// if (!strArg[1].Replace("\"", "").Trim().Equals(""))
// {
// if (i == 0)
// {
// sorts.prop = strArg[1].Replace("\"", "");
// }
// else
// {
// sorts.dire = strArg[1].Replace("\"", "");
// }
// }
// }
//}
//return sorts.prop + " " + sorts.dire;
}
else
{
return "";
}
}
}
}