protected static FR_Guid Execute(DbConnection Connection, DbTransaction Transaction, P_L3MP_DP_1145 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { //Leave UserCode region to enable user code saving #region UserCode var returnValue = new FR_Guid(); ORM_CMN_PRO_Product item = new ORM_CMN_PRO_Product(); var result = item.Load(Connection, Transaction, Parameter.CMN_PRO_ProductID); if (result.Status != FR_Status.Success) { var error = new FR_Guid(); error.ErrorMessage = "No Such ID"; error.Status = FR_Status.Error_Internal; return(error); } /**********************Delete Hec_Product***********************************/ var hecProductQuery = new ORM_HEC_Product.Query(); hecProductQuery.Ext_PRO_Product_RefID = Parameter.CMN_PRO_ProductID; hecProductQuery.IsDeleted = false; var medProduct = ORM_HEC_Product.Query.Search(Connection, Transaction, hecProductQuery).FirstOrDefault(); if (medProduct != null) { medProduct.IsDeleted = true; medProduct.Save(Connection, Transaction); } /**********************Delete Surveys***************************************/ var surveysQuery = new ORM_CMN_PRO_Product_Questionnaire_Assignment.Query(); surveysQuery.CMN_PRO_Product_RefID = Parameter.CMN_PRO_ProductID; surveysQuery.IsDeleted = false; var surveyes = ORM_CMN_PRO_Product_Questionnaire_Assignment.Query.Search(Connection, Transaction, surveysQuery).ToList(); if (surveyes.Count != 0) { foreach (var survey in surveyes) { survey.IsDeleted = true; survey.Save(Connection, Transaction); } } item.IsDeleted = true; item.Save(Connection, Transaction); return(returnValue); #endregion UserCode }
protected static FR_L3MP_GPfTID_1602_Array Execute(DbConnection Connection, DbTransaction Transaction, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { //Leave UserCode region to enable user code saving #region UserCode var returnValue = new FR_L3MP_GPfTID_1602_Array(); List <L2PD_GAPfTI_1541> allProducts = cls_Get_Product_for_TenantID.Invoke(Connection, Transaction, securityTicket).Result.ToList(); List <L3MP_GPfTID_1602> sortedData = new List <L3MP_GPfTID_1602>(); for (int i = 0; i < allProducts.Count; i++) { //Ovo ce se brisati################################# var cmn_pro_product_2_productGroupQuery = new ORM_CMN_PRO_Product_2_ProductGroup.Query(); cmn_pro_product_2_productGroupQuery.Tenant_RefID = securityTicket.TenantID; cmn_pro_product_2_productGroupQuery.CMN_PRO_Product_RefID = allProducts[i].CMN_PRO_ProductID; cmn_pro_product_2_productGroupQuery.IsDeleted = false; var cmn_pro_product_2_productGroup = ORM_CMN_PRO_Product_2_ProductGroup.Query.Search(Connection, Transaction, cmn_pro_product_2_productGroupQuery).FirstOrDefault(); //################################# if (cmn_pro_product_2_productGroup == null) { L3MP_GPfTID_1602 product = new L3MP_GPfTID_1602(); product.CMN_PRO_ProductID = allProducts[i].CMN_PRO_ProductID; product.Creation_Timestamp = allProducts[i].Creation_Timestamp; product.Product_Description = allProducts[i].Product_Description; product.Product_Name_DictID = allProducts[i].Product_Name_DictID; product.Product_Number = allProducts[i].Product_Number; product.Tenant_RefID = allProducts[i].Tenant_RefID; #region Surveys var surveysQuery = new ORM_CMN_PRO_Product_Questionnaire_Assignment.Query(); surveysQuery.CMN_PRO_Product_RefID = allProducts[i].CMN_PRO_ProductID; surveysQuery.IsDeleted = false; var surveyes = ORM_CMN_PRO_Product_Questionnaire_Assignment.Query.Search(Connection, Transaction, surveysQuery).ToList(); if (surveyes.Count != 0) { List <L3MP_GPfTID_1602_Surveys> listOfSurveys = new List <L3MP_GPfTID_1602_Surveys>(); foreach (var survey in surveyes) { L3MP_GPfTID_1602_Surveys surveyData = new L3MP_GPfTID_1602_Surveys(); surveyData.CMN_PRO_Product_Questionnaire_AssignmentID = survey.CMN_PRO_Product_Questionnaire_AssignmentID; listOfSurveys.Add(surveyData); } product.Surveys = listOfSurveys.ToArray(); } #endregion #region Medical_ProductData var medicalProductDataQuery = new ORM_HEC_Product.Query(); medicalProductDataQuery.Ext_PRO_Product_RefID = allProducts[i].CMN_PRO_ProductID; medicalProductDataQuery.IsDeleted = false; var medicalProductData = ORM_HEC_Product.Query.Search(Connection, Transaction, medicalProductDataQuery).FirstOrDefault(); if (medicalProductData != null) { L3MP_GPfTID_1602_Medical_ProductData productData = new L3MP_GPfTID_1602_Medical_ProductData(); productData.HEC_ProductID = medicalProductData.HEC_ProductID; productData.Recepie = medicalProductData.Recepie; product.Medical_ProductData = productData; } #endregion sortedData.Add(product); } else { continue; } } returnValue.Result = sortedData.ToArray(); return(returnValue); #endregion UserCode }