public async Task <IActionResult> Success() { //This action returns the result of the payment. //This is when the order will receive it's first update: it's either payed or encountered an error. var result = PDTHolder.Success(Request.Query["tx"].ToString()); //Update the order status and history, update the offeredservice //Get previously entered order information string form = HttpContext.Session.GetString("FORM"); char separator = ';'; string[] formVars = form.Split(separator); //Send a confirmation email await ConstructOrderVerificationMailAsync(formVars); string email = formVars[4]; List <int> offeredServiceIds = ParsePursToList(); foreach (int olsId in offeredServiceIds) { //Fetch the order id int orderId = MollShopContext.FindOrderId(olsId, email); //Insert a new order history tbl_orderhistory history = new tbl_orderhistory(); history.fld_ActionDate = DateTime.Now; history.fld_lastAction = "Paid order"; history.fld_orderstatus = "Sent"; history.fld_orderid = orderId; MollShopContext.CreateRow(history, "tbl_orderhistory"); //Insert a new order status tbl_orderstatus orderStatus = new tbl_orderstatus(); orderStatus.fld_dateOrdered = DateTime.Now; orderStatus.fld_orderid = orderId; orderStatus.fld_targetDeliveryDate = DateTime.Now.AddDays(7); orderStatus.fld_DateUpdated = DateTime.Now; MollShopContext.CreateRow(orderStatus); //Set the availability of the service to 'N' //ElasticSearch EsUpdater <OfferedLabourerService> .UpdateField("" + olsId, "fld_stillavailable", 'N'); //Database tbl_offeredservicesdata os = new tbl_offeredservicesdata(); os.fld_stillavailable = 'N'; MollShopContext.UpdateRow(os, "fld_OfferedServiceId", olsId); } return(View("Success")); }