public OfferedLabourerService UpdateOLS(string insertedDic) { tbl_offeredservicesdata currentOffer = JsonConvert.DeserializeObject <tbl_offeredservicesdata>(insertedDic); MollShopContext.UpdateRow(currentOffer, "fld_offeredserviceid", currentOffer.fld_offeredserviceid); //Because ElasticSearch does not support decimal numbers, we must multiply the cost by a 100 currentOffer.fld_cost = currentOffer.fld_cost * 100; OfferedLabourerService currentOLS = EsOLSQuery <OfferedLabourerService> .findByOfferedServiceId(currentOffer.fld_offeredserviceid); currentOLS.fld_cost = currentOffer.fld_cost; currentOLS.fld_area = currentOffer.fld_area; currentOLS.fld_timefirst = currentOffer.fld_timefirst; currentOLS.fld_timelast = currentOffer.fld_timelast; currentOLS.fld_stillavailable = currentOffer.fld_stillavailable; EsUpdater <OfferedLabourerService> .UpsertDocument(currentOLS, "moll_ols", "OLS", currentOLS.fld_offeredserviceid); //To render it correctly in the datatable, we divice the cost by 100 again currentOLS.fld_cost = currentOLS.fld_cost / 100; return(currentOLS); }
public IActionResult ChangeAccount(tbl_userdata user) { MollShopContext.UpdateRow(user, "fld_userid", (int)HttpContext.Session.GetInt32("UserId")); if (user.fld_username != null) { HttpContext.Session.SetString("UserName", user.fld_username); } return(RedirectToAction("MyAccount", "Account")); }
public int EditItem(string insertedDic, string type) { switch (type) { case "tbl_userdata": try { tbl_userdata currentUser = JsonConvert.DeserializeObject <tbl_userdata>(insertedDic); //Dates and ElasticSearch do not mix very well, so we do a little check beforehand if (currentUser.fld_dateofbirth == "") { currentUser.fld_dateofbirth = null; } EsUpdater <tbl_userdata> .UpsertDocument(currentUser, "moll_users", "User", currentUser.fld_userid); MollShopContext.UpdateRow(currentUser, "fld_UserId", currentUser.fld_userid); } catch (Exception e) { return(-1); } break; case "tbl_servicedata": tbl_servicedata currentService = JsonConvert.DeserializeObject <tbl_servicedata>(insertedDic); //Update the stand-alone service document EsUpdater <tbl_servicedata> .UpsertDocument(currentService, "moll_dataservices", "Services", currentService.fld_serviceid); //Find all OLS documents in ES that contain this service List <OfferedLabourerService> packages = EsOLSQuery <OfferedLabourerService> .getByService(currentService.fld_serviceid); //Foreach OLS ID, update it with the current service foreach (OfferedLabourerService package in packages) { package.fld_name = currentService.fld_name; package.fld_category = currentService.fld_category; package.fld_description = currentService.fld_description; package.fld_imagelink = currentService.fld_imagelink; EsUpdater <OfferedLabourerService> .UpsertDocument(package, "moll_ols", "OLS", package.fld_offeredserviceid); } MollShopContext.UpdateRow(currentService, "fld_ServiceId", currentService.fld_serviceid); break; case "tbl_labourerdata": tbl_labourerdata currentLabourer = JsonConvert.DeserializeObject <tbl_labourerdata>(insertedDic); //Update the stand-alone labourer document EsUpdater <tbl_labourerdata> .UpsertDocument(currentLabourer, "moll_labourers", "Labourer", currentLabourer.fld_labourerid); //Find all OLS documents in ES that contain this labourer List <OfferedLabourerService> olspackages = EsOLSQuery <OfferedLabourerService> .getByLabourer(currentLabourer.fld_labourerid); //Foreach OLS Id, update it with the current labourer foreach (OfferedLabourerService package in olspackages) { package.fld_address = currentLabourer.fld_address; package.fld_firstname = currentLabourer.fld_firstname; package.fld_email = currentLabourer.fld_email; package.fld_gender = currentLabourer.fld_gender; package.fld_lastname = currentLabourer.fld_lastname; package.fld_phonenumber = currentLabourer.fld_phonenumber; package.fld_zipcode = currentLabourer.fld_zipcode; EsUpdater <OfferedLabourerService> .UpsertDocument(package, "moll_ols", "OLS", package.fld_offeredserviceid); } MollShopContext.UpdateRow(currentLabourer, "fld_LabourerId", currentLabourer.fld_labourerid); break; default: break; } return(1); }
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")); }