Here I using asp.net mvc core application with web and webapi, I want to pass ISGrid model from api to web to render grid but there was an error while Serialize and Deserializeing the object refer my code below
here I get ISGrid object :
public ISGrid<WorkflowsModel> GetAllOrders(Action<IGridColumnCollection<OrderModel>> columns, QueryDictionary<string> query)
{
var repo = orderRepo.GetQueryAsNoTracking().Include(x => x.products).Select(m => new OrderModel()
{
Id = m.Id,
Name = m.Name,
Price= m.Price,
Count = m.Count,
});
GridServer<OrderModel> server = (GridServer<OrderModel>)new GridServer<OrderModel>(repo, query, false, "orderGrid",
columns, 10)
.Sortable()
.Filterable()
.WithMultipleFilters()
.SetToListAsyncFunc(async x => x.ToList());
return server.Grid;
}
public GridqueryModel<OrderModel> GetAllOrders(GridqueryModel<OrderModel> model)
{
Action<IGridColumnCollection<OrderModel>> columns = c =>
{
c.Add(o => o.Name)
.Titled("Name");
c.Add(o => o.Price)
.Titled("Price");
c.Add(o => o.Count)
.Titled("Count");
c.Add().Encoded(false).Sanitized(false)
.Titled("Action")
.RenderValueAs(o => $"<a href='../OrderManager/OrderGet?id={o.Id}&formid={o.Id}'><i class='fas fa-edit'></i></a>");
};
var query = new QueryDictionary<string>();
model.data = workflowDBService.GetAllOrders(columns, query);
try
{
var settings = new JsonSerializerSettings
{
ReferenceLoopHandling = ReferenceLoopHandling.Ignore,
// TypeNameHandling = TypeNameHandling.All,
PreserveReferencesHandling = PreserveReferencesHandling.None,
NullValueHandling = NullValueHandling.Ignore
};
var deserializedObj = JsonConvert.SerializeObject(model.data, typeof(ISGrid<OrderModel>), settings);
var data = JsonConvert.DeserializeObject<ISGrid<OrderModel>>(deserializedObj, settings);
}
catch (Exception e)
{
logger.LogError(e.Message);
}
return model;
}
here I am facing error in SerializeObject and DeserializeObject
Here I using asp.net mvc core application with web and webapi, I want to pass ISGrid model from api to web to render grid but there was an error while Serialize and Deserializeing the object refer my code below
here I get ISGrid object :
here I am facing error in SerializeObject and DeserializeObject