/// <summary> /// This method allows to get the list's documents without the elements to make them shorter /// </summary> /// <author> /// Luis Gonzalo Quijada Romero /// </author> /// <returns> /// Returns a JSON with the list's information /// </returns> public JsonResult getListTable() { if (this.Request.IsAjaxRequest()) { try { List <BsonDocument> resultList = listTable.getRows(); foreach (BsonDocument document in resultList) { try //trying to remove the elements field { document.Remove("elements"); } catch (Exception e) { /*Ignored*/ } try //trying to set the user creator's name { BsonDocument user = userTable.getRow(document.GetElement("creatorId").Value.ToString()); document.Set("creatorId", user.GetElement("user").Value); } catch (Exception e) { //if it can't be created remove it, we can't show the id document.Remove("creatorId"); } } return(Json(resultList.ToJson())); } catch (Exception e) { return(null); //if an error occours returns no document } } return(null); }