Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I solved it this way:</p> <p><strong>StockLinesController.cs</strong></p> <pre><code>/// &lt;summary&gt; /// Service returning API's StockLine that matches the given DeliveryNote id. /// &lt;/summary&gt; /// &lt;param name="DeliveryNoteLineId"&gt;The id of the DeliveryNoteLine that created the StockLine&lt;/param&gt; /// &lt;returns&gt;Returns the StockLine created by the given DeliveryNoteLine&lt;/returns&gt; public ActionResult GetStockLine(string DeliveryNoteLineId) { // Only perform the request if the data is outdated, otherwise use cached data. if (DateTime.Now.AddMinutes(-10) &gt; _cacheStockLines_lastCall.GetValueOrDefault(DateTime.MinValue)) { var request = new RestSharp.RestRequest("StockLines/Get", RestSharp.Method.GET) { RequestFormat = RestSharp.DataFormat.Json }; var response = Client.Execute(request); _cacheStockLines = DeserializeResponse&lt;List&lt;StockLine&gt;&gt;(response); _cacheStockLines_lastCall = DateTime.Now; } // Return the stock line created by the delivery note line introduced my parameter var ret = _cacheStockLines .Where(x =&gt; (x.DeliveryNoteLine != null &amp;&amp; x.DeliveryNoteLine.Id == DeliveryNoteLineId)) .Select(x =&gt; new { label = "ID", value = x.Id }); return Json(ret, JsonRequestBehavior.AllowGet); } </code></pre> <p><strong>DeliveryNoteLinesController.cs</strong></p> <pre><code>/// &lt;summary&gt; /// Handles the POST event for the Delete action. /// &lt;/summary&gt; /// &lt;param name="id"&gt;Id of the TEntity object to delete.&lt;/param&gt; /// &lt;param name="model"&gt;TEntity object to delete.&lt;/param&gt; /// &lt;returns&gt;Redirection to the Index action if succeeded, the Delete View otherwise.&lt;/returns&gt; [HttpPost] public override ActionResult Delete(string id, DeliveryNoteLine model) { //This code deletes the StockLine var stocks_request = new RestSharp.RestRequest("GetStockLine?DeliveryNoteLineId={id}", RestSharp.Method.GET) { RequestFormat = RestSharp.DataFormat.Json } .AddParameter("id", id, RestSharp.ParameterType.UrlSegment); var stocks_response = Client.Execute(stocks_request); var stockline = DeserializeResponse&lt;StockLine&gt;(stocks_response); var reqdelstk = new RestSharp.RestRequest("StockLine?id={id}", RestSharp.Method.DELETE) { RequestFormat = RestSharp.DataFormat.Json } .AddParameter("id", stockline.Id, RestSharp.ParameterType.UrlSegment); var resdelstk = Client.Execute(reqdelstk); //This code deletes the DeliveryNoteLine var request = new RestSharp.RestRequest(Resource + "?id={id}", RestSharp.Method.DELETE) { RequestFormat = RestSharp.DataFormat.Json } .AddParameter("id", id, RestSharp.ParameterType.UrlSegment); var response = Client.Execute(request); // Handle response errors HandleResponseErrors(response); if (Errors.Length == 0) return RedirectToAction("Index"); else { request = new RestSharp.RestRequest(Resource + "?id={id}", RestSharp.Method.GET) { RequestFormat = RestSharp.DataFormat.Json } .AddParameter("id", id, RestSharp.ParameterType.UrlSegment); response = Client.Execute(request); model = DeserializeResponse&lt;DeliveryNoteLine&gt;(response); ViewBag.Errors = Errors; return View(model); } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload