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); }