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 OLS ConstructOLS(tbl_servicedata service, tbl_labourerdata labourer, tbl_offeredservicesdata offeredServiceObj) { OLS ols = new OLS(); ols.fld_addedtowishlist = 0; ols.fld_address = labourer.fld_address; ols.fld_area = offeredServiceObj.fld_area; ols.fld_category = service.fld_category; ols.fld_cost = Convert.ToInt32(offeredServiceObj.fld_cost * 100); ols.fld_dateofbirth = labourer.fld_dateofbirth; ols.fld_description = service.fld_description; ols.fld_email = labourer.fld_email; ols.fld_firstname = labourer.fld_firstname; ols.fld_gender = labourer.fld_gender; ols.fld_imagelink = service.fld_imagelink; ols.fld_labourerid = labourer.fld_labourerid; ols.fld_lastname = labourer.fld_lastname; ols.fld_name = service.fld_name; ols.fld_phonenumber = labourer.fld_phonenumber; ols.fld_serviceid = service.fld_serviceid; ols.fld_stillavailable = offeredServiceObj.fld_stillavailable; ols.fld_timefirst = offeredServiceObj.fld_timefirst.ToString(); ols.fld_timelast = offeredServiceObj.fld_timelast.ToString(); ols.fld_timesbought = offeredServiceObj.fld_timesbought; ols.fld_zipcode = labourer.fld_zipcode; ols.fld_offeredserviceid = offeredServiceObj.fld_offeredserviceid; return(ols); }
public IActionResult OLSPreview(string offeredService, string serviceId, string labourerId) { tbl_servicedata service = EsServiceQuery.FindById(Convert.ToInt32(serviceId)); tbl_labourerdata labourer = EsLabourerQuery.FindById(Convert.ToInt32(labourerId)); tbl_offeredservicesdata offeredServiceObj = JsonConvert.DeserializeObject <tbl_offeredservicesdata>(offeredService); offeredServiceObj.fld_offeredserviceid = 0; OLS ols = ConstructOLS(service, labourer, offeredServiceObj); return(PartialView("OLSPreview", ols)); }
public OLS CreateOLS(string offeredService, string serviceId, string labourerId) { tbl_servicedata service = EsServiceQuery.FindById(Convert.ToInt32(serviceId)); tbl_labourerdata labourer = EsLabourerQuery.FindById(Convert.ToInt32(labourerId)); tbl_offeredservicesdata offeredServiceObj = JsonConvert.DeserializeObject <tbl_offeredservicesdata>(offeredService); offeredServiceObj.fld_labourerid = labourer.fld_labourerid; offeredServiceObj.fld_serviceid = service.fld_serviceid; offeredServiceObj.fld_offeredserviceid = MollShopContext.CreateRow(offeredServiceObj, "tbl_offeredservicesdata"); OLS ols = ConstructOLS(service, labourer, offeredServiceObj); //Because ElasticSearch does not support decimal numbers, we must multiply the cost by a 100 ols.fld_cost = ols.fld_cost * 100; EsUpdater <OLS> .InsertDocument(ols, "moll_ols", "OLS", ols.fld_offeredserviceid.ToString()); //return the OfferedLabourerService, so we can later render it into the Datatable on the ManageOLS page //We must divide the cost by a 100 again, to render it correctly ols.fld_cost = ols.fld_cost / 100; return(ols); }
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")); }