/// <summary> /// Handler for a get (search) request. /// </summary> /// <param name="values">The values.</param> /// <returns>The JSON encoded request results</returns> public JsonResult Get(string[] values) { try { if (values == null) { throw new Exception("No table/column/values given for GET"); } values = values[0].Split('/'); bool purchaseOrder = false; if (values[0].Equals("true", StringComparison.CurrentCultureIgnoreCase)) { purchaseOrder = true; // Remove the purchase order item values = values.Skip(1).ToArray(); } else if (values[0].Equals("false", StringComparison.CurrentCultureIgnoreCase)) { purchaseOrder = false; // Remove the purchase order item values = values.Skip(1).ToArray(); } var queries = TableQuery.ListQueriesFromPath(values); var data = ServerServiceRequest.FromTableQueries(queries.Select(q => q.ToTableColumnValue()).ToList()); var searcher = new DatabaseSearch(data, purchaseOrder); var results = searcher.Search(); return(Json(results, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { Logger.GetInstance().Write(ex); return(Json(new JsonError(ex), JsonRequestBehavior.AllowGet)); } }
/// <summary> /// Handler for a delete request /// </summary> /// <param name="values">The values.</param> /// <returns>The JSON encoded delete request results</returns> public JsonResult Delete(string[] values) { try { if (values == null) { throw new Exception("No table/column/values given for DELETE"); } values = values[0].Split('/'); var queries = TableQuery.ListQueriesFromPath(values); var data = ServerServiceRequest.FromTableQueries(queries.Select(q => q.ToTableColumnValue()).ToList()); new DatabaseUpdate(data).Delete(); return(Json(new JsonSuccess("OK", "Successfully Deleted"))); } catch (Exception ex) { Logger.GetInstance().Write(ex); return(Json(new JsonError(ex), JsonRequestBehavior.AllowGet)); } }