private static List <L5CA_GACPfR_1621> ProductWithoutPrices(DbConnection Connection, DbTransaction Transaction, P_L5CA_PNCV_1520 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket, List <ORM_CMN_PRO_Catalog_Product> oldProducts) { List <L5CA_GACPfR_1621> products = new List <L5CA_GACPfR_1621>(); L5CA_GACPfR_1621 product; List <Guid> insertedProducts = new List <Guid>(); foreach (var item in oldProducts) { if (insertedProducts.Any(i => i == item.CMN_PRO_Product_RefID)) { continue; } insertedProducts.Add(item.CMN_PRO_Product_RefID); ORM_CMN_SLS_Pricelist_Release plr = new ORM_CMN_SLS_Pricelist_Release(); plr.Load(Connection, Transaction, Parameter.Default_PricelistRelease_RefID); var pricelistPriceQry = new ORM_CMN_SLS_Price.Query() { CMN_PRO_Product_RefID = item.CMN_PRO_Product_RefID, PricelistRelease_RefID = plr.CMN_SLS_Pricelist_ReleaseID, IsDeleted = false, Tenant_RefID = securityTicket.TenantID }; var prices = ORM_CMN_SLS_Price.Query.Search(Connection, Transaction, pricelistPriceQry); if (prices.Count == 0) { ORM_CMN_PRO_Product pr = new ORM_CMN_PRO_Product(); pr.Load(Connection, Transaction, item.CMN_PRO_Product_RefID); product = new L5CA_GACPfR_1621(); product.Product_Number = pr.Product_Number; product.Product_Name = pr.Product_Name; product.Product_Description = pr.Product_Description; products.Add(product); } } return(products); }
protected static FR_L6WS_GSCDfSCID_1458 Execute(DbConnection Connection, DbTransaction Transaction, P_L6WS_GSCDfSCID_1458 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { #region UserCode var returnValue = new FR_L6WS_GSCDfSCID_1458(); //Put your code here if (Parameter.ShoppingCartID == Guid.Empty) { return(null); } returnValue.Result = new L6WS_GSCDfSCID_1458(); #region ShoppingCart returnValue.Result.ShoppingCart = cls_Get_ShoppingCart_for_ShoppingCartID.Invoke(Connection, Transaction, new P_L6WS_GSCfSCID_1448() { ShoppingCartID = Parameter.ShoppingCartID }, securityTicket).Result; if (returnValue.Result.ShoppingCart == null) { return(null); } #endregion #region ShoppingCart_Notes returnValue.Result.ShoppingCart_Notes = cls_Get_ShoppingCart_Notes_for_ShoppingCartID.Invoke(Connection, Transaction, new P_L5AWSAR_GSCNfSC_1454() { ShoppingCartID = Parameter.ShoppingCartID }, securityTicket).Result.OrderBy(i => i.UpdatedOn).ToArray(); #endregion #region Articles ORM_ORD_PRC_ShoppingCart_Product.Query shoppingCartProductsQuery = new ORM_ORD_PRC_ShoppingCart_Product.Query(); shoppingCartProductsQuery.ORD_PRC_ShoppingCart_RefID = returnValue.Result.ShoppingCart.ORD_PRC_ShoppingCartID; shoppingCartProductsQuery.IsDeleted = false; shoppingCartProductsQuery.IsCanceled = false; shoppingCartProductsQuery.Tenant_RefID = securityTicket.TenantID; List <ORM_ORD_PRC_ShoppingCart_Product> productList = ORM_ORD_PRC_ShoppingCart_Product.Query.Search(Connection, Transaction, shoppingCartProductsQuery); List <Guid> articleIds = new List <Guid>(); if (productList != null && productList.Count > 0) { articleIds.AddRange(productList.Select(i => i.CMN_PRO_Product_RefID)); } List <L3AR_GAfAL_0942> articleInfos = new List <L3AR_GAfAL_0942>(); if (articleIds.Count > 0) { articleInfos = cls_Get_Articles_for_ArticleList.Invoke(Connection, Transaction, new P_L3AR_GAfAL_0942() { ProductID_List = articleIds.ToArray() }, securityTicket).Result.ToList(); } List <L6WS_GSCDfSCID_1458_Product> products = new List <L6WS_GSCDfSCID_1458_Product>(); L6WS_GSCDfSCID_1458_Product product; L3AR_GAfAL_0942 articleInfo; double taxRate = 0; #region ORM and Querie objects ORM_CMN_PRO_Product orm_product; ORM_CMN_SLS_Price.Query priceQuery; ORM_CMN_PRO_Product_SalesTaxAssignmnet.Query taxAssignmentQuery; ORM_ACC_TAX_Tax orm_tax; #endregion foreach (var productItem in productList) { #region check procurement order date and number if (returnValue.Result.OrderDate == null || returnValue.Result.OrderDate.Ticks == 0) { ORM_ORD_PRC_ShoppingCart_2_ProcurementOrderPosition.Query shoppingCartOrderPositionQuery = new ORM_ORD_PRC_ShoppingCart_2_ProcurementOrderPosition.Query(); shoppingCartOrderPositionQuery.IsDeleted = false; shoppingCartOrderPositionQuery.Tenant_RefID = securityTicket.TenantID; shoppingCartOrderPositionQuery.ORD_PRC_ShoppingCart_Product_RefID = productItem.ORD_PRC_ShoppingCart_ProductID; List <ORM_ORD_PRC_ShoppingCart_2_ProcurementOrderPosition> shoppingCartOrderPositionList = ORM_ORD_PRC_ShoppingCart_2_ProcurementOrderPosition.Query.Search(Connection, Transaction, shoppingCartOrderPositionQuery); foreach (var shoppingCartOrderPosition in shoppingCartOrderPositionList) { ORM_ORD_PRC_ProcurementOrder_Position procurementOrder_Position = new ORM_ORD_PRC_ProcurementOrder_Position(); var procurementOrder_PositionResult = procurementOrder_Position.Load(Connection, Transaction, shoppingCartOrderPosition.ORD_PRC_ProcurementOrder_Position_RefID); if (procurementOrder_PositionResult.Status != FR_Status.Success || procurementOrder_Position.ORD_PRC_ProcurementOrder_PositionID == Guid.Empty) { continue; } ORM_ORD_PRC_ProcurementOrder_Header procurementOrder_Header = new ORM_ORD_PRC_ProcurementOrder_Header(); var procurementOrder_HeaderResult = procurementOrder_Header.Load(Connection, Transaction, procurementOrder_Position.ProcurementOrder_Header_RefID); if (procurementOrder_HeaderResult.Status != FR_Status.Success || procurementOrder_Header.ORD_PRC_ProcurementOrder_HeaderID == Guid.Empty) { continue; } returnValue.Result.OrderDate = procurementOrder_Header.ProcurementOrder_Date; returnValue.Result.OrderNumber = procurementOrder_Header.ProcurementOrder_Number; break; } } #endregion #region get product orm_product = new ORM_CMN_PRO_Product(); var productResult = orm_product.Load(Connection, Transaction, productItem.CMN_PRO_Product_RefID); if (productResult.Status != FR_Status.Success || orm_product.CMN_PRO_ProductID == Guid.Empty) { continue; } #endregion #region get price ORM_CMN_PRO_SubscribedCatalog.Query catalogQuery = new ORM_CMN_PRO_SubscribedCatalog.Query(); catalogQuery.Tenant_RefID = securityTicket.TenantID; catalogQuery.IsDeleted = false; List <ORM_CMN_PRO_SubscribedCatalog> catalogList = ORM_CMN_PRO_SubscribedCatalog.Query.Search(Connection, Transaction, catalogQuery); priceQuery = new ORM_CMN_SLS_Price.Query(); priceQuery.CMN_PRO_Product_RefID = orm_product.CMN_PRO_ProductID; priceQuery.Tenant_RefID = securityTicket.TenantID; priceQuery.IsDeleted = false; List <ORM_CMN_SLS_Price> prices = ORM_CMN_SLS_Price.Query.Search(Connection, Transaction, priceQuery); ORM_CMN_SLS_Price price = prices.Where(i => catalogList.Select(j => j.SubscribedCatalog_PricelistRelease_RefID).Contains(i.PricelistRelease_RefID)).FirstOrDefault(); #endregion #region get taxes taxRate = 0; taxAssignmentQuery = new ORM_CMN_PRO_Product_SalesTaxAssignmnet.Query(); taxAssignmentQuery.Product_RefID = orm_product.CMN_PRO_ProductID; taxAssignmentQuery.Tenant_RefID = securityTicket.TenantID; taxAssignmentQuery.IsDeleted = false; List <ORM_CMN_PRO_Product_SalesTaxAssignmnet> taxAssignmentList = ORM_CMN_PRO_Product_SalesTaxAssignmnet.Query.Search(Connection, Transaction, taxAssignmentQuery); foreach (var taxAssignment in taxAssignmentList) { orm_tax = new ORM_ACC_TAX_Tax(); var taxResult = orm_tax.Load(Connection, Transaction, taxAssignment.ApplicableSalesTax_RefID); if (taxResult.Status == FR_Status.Success && orm_tax.ACC_TAX_TaxeID != Guid.Empty) { taxRate += orm_tax.TaxRate; } } #endregion #region set product item product = new L6WS_GSCDfSCID_1458_Product(); product.CMN_PRO_Product_RefID = orm_product.CMN_PRO_ProductID; product.PriceAmount = price == null ? 0 : (price.PriceAmount == null ? 0 : Double.Parse(price.PriceAmount.ToString())); product.TaxRate = taxRate; product.Quantity = productItem.Quantity.ToString(); product.IsProductCanceled = productItem.IsCanceled; if (!String.IsNullOrEmpty(productItem.Comment)) { string[] comments = productItem.Comment.Split('@'); if (comments.Length == 2) { product.ProductComment = comments[1]; } } product.IsProductReplacementAllowed = productItem.IsProductReplacementAllowed; articleInfo = articleInfos.FirstOrDefault(i => i.CMN_PRO_ProductID == orm_product.CMN_PRO_ProductID); if (articleInfo != null) { product.Product_Name = articleInfo.Product_Name; product.Product_Number = articleInfo.Product_Number; product.UnitAmount = articleInfo.UnitAmount.ToString(); product.UnitIsoCode = articleInfo.UnitIsoCode; product.DossageFormName = articleInfo.DossageFormName; } #endregion products.Add(product); } returnValue.Result.Products = products.ToArray(); #endregion #region Person info // current user ORM_CMN_PER_PersonInfo_2_Account.Query accountQuery = new ORM_CMN_PER_PersonInfo_2_Account.Query(); accountQuery.USR_Account_RefID = securityTicket.AccountID; accountQuery.Tenant_RefID = securityTicket.TenantID; accountQuery.IsDeleted = false; ORM_CMN_PER_PersonInfo_2_Account account = ORM_CMN_PER_PersonInfo_2_Account.Query.Search(Connection, Transaction, accountQuery).FirstOrDefault(); if (account != null) { ORM_CMN_PER_PersonInfo personInfo = new ORM_CMN_PER_PersonInfo(); var personInfoResult = personInfo.Load(Connection, Transaction, account.CMN_PER_PersonInfo_RefID); if (personInfoResult.Status == FR_Status.Success && personInfo.CMN_PER_PersonInfoID != Guid.Empty) { returnValue.Result.CurrentUser = personInfo.FirstName + " " + personInfo.LastName; } } #region Approved by user ORM_ORD_PRC_ShoppingCart_Status.Query stusesQuery = new ORM_ORD_PRC_ShoppingCart_Status.Query(); stusesQuery.Tenant_RefID = securityTicket.TenantID; stusesQuery.IsDeleted = false; List <ORM_ORD_PRC_ShoppingCart_Status> statuses = ORM_ORD_PRC_ShoppingCart_Status.Query.Search(Connection, Transaction, stusesQuery); ORM_ORD_PRC_ShoppingCart_Status approvedStatus = statuses.FirstOrDefault(i => i.GlobalPropertyMatchingID.Contains("approved")); if (approvedStatus != null) { ORM_ORD_PRC_ShoppingCartStatus_History.Query statusHistoryQuery = new ORM_ORD_PRC_ShoppingCartStatus_History.Query(); statusHistoryQuery.Tenant_RefID = securityTicket.TenantID; statusHistoryQuery.IsDeleted = false; statusHistoryQuery.ORD_PRC_ShoppingCart_RefID = returnValue.Result.ShoppingCart.ORD_PRC_ShoppingCartID; statusHistoryQuery.ORD_PRC_ShoppingCart_Status_RefID = approvedStatus.ORD_PRC_ShoppingCart_StatusID; ORM_ORD_PRC_ShoppingCartStatus_History statusHistory = ORM_ORD_PRC_ShoppingCartStatus_History.Query.Search(Connection, Transaction, statusHistoryQuery).FirstOrDefault(); if (statusHistory != null) { accountQuery = new ORM_CMN_PER_PersonInfo_2_Account.Query(); accountQuery.USR_Account_RefID = statusHistory.PerformedBy_Account_RefID; accountQuery.Tenant_RefID = securityTicket.TenantID; accountQuery.IsDeleted = false; account = ORM_CMN_PER_PersonInfo_2_Account.Query.Search(Connection, Transaction, accountQuery).FirstOrDefault(); if (account != null) { ORM_CMN_PER_PersonInfo personInfo = new ORM_CMN_PER_PersonInfo(); var personInfoResult = personInfo.Load(Connection, Transaction, account.CMN_PER_PersonInfo_RefID); if (personInfoResult.Status == FR_Status.Success && personInfo.CMN_PER_PersonInfoID != Guid.Empty) { returnValue.Result.ApprovedByUser = personInfo.FirstName + " " + personInfo.LastName; returnValue.Result.DateOfApproval = statusHistory.Creation_Timestamp; } } } } #endregion #endregion return(returnValue); #endregion UserCode }
protected static FR_L5CA_PNCV_1603 Execute(DbConnection Connection, DbTransaction Transaction, P_L5CA_PNCV_1603 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { #region UserCode var returnValue = new FR_L5CA_PNCV_1603(); returnValue.Result = new L5CA_PNCV_1603(); var account = new ORM_USR_Account(); account.Load(Connection, Transaction, securityTicket.AccountID); #region Update active catalog revision ORM_CMN_PRO_Catalog_Revision rev = new ORM_CMN_PRO_Catalog_Revision(); rev.Load(Connection, Transaction, Parameter.CMN_PRO_Catalog_RevisionID); rev.Valid_From = Parameter.Valid_From; rev.Valid_Through = Parameter.Valid_Through; rev.Default_PricelistRelease_RefID = Parameter.Default_PricelistRelease_RefID; rev.PublishedBy_BusinessParticipant_RefID = account.BusinessParticipant_RefID; rev.PublishedOn_Date = DateTime.Now; rev.Save(Connection, Transaction); #endregion #region Create new catalog revision ORM_CMN_PRO_Catalog_Revision newRev = new ORM_CMN_PRO_Catalog_Revision(); newRev.CMN_PRO_Catalog_RevisionID = Guid.NewGuid(); newRev.CMN_PRO_Catalog_RefID = rev.CMN_PRO_Catalog_RefID; newRev.Tenant_RefID = securityTicket.TenantID; newRev.Creation_Timestamp = DateTime.Now; newRev.CatalogRevision_Description = "Revision for Catalog"; newRev.CatalogRevision_Name = "New Catalog Revision"; newRev.IsDeleted = false; newRev.RevisionNumber = rev.RevisionNumber + 1; newRev.Save(Connection, Transaction); #endregion #region Products var oldProducts = ORM_CMN_PRO_Catalog_Product.Query.Search(Connection, Transaction, new ORM_CMN_PRO_Catalog_Product.Query() { CMN_PRO_Catalog_Revision_RefID = rev.CMN_PRO_Catalog_RevisionID, IsDeleted = false }); if (oldProducts.Count == 0) { returnValue.Result.Status_Code = -1; // -1 no products in revision returnValue.Result.Status_Message = "no products in revision"; return(returnValue); } //oldProductID - newProductID Dictionary <Guid, Guid> productsMapping = new Dictionary <Guid, Guid>(); foreach (var item in oldProducts) { ORM_CMN_SLS_Pricelist_Release plr = new ORM_CMN_SLS_Pricelist_Release(); plr.Load(Connection, Transaction, Parameter.Default_PricelistRelease_RefID); var pricelistPriceQry = new ORM_CMN_SLS_Price.Query() { CMN_PRO_Product_RefID = item.CMN_PRO_Product_RefID, PricelistRelease_RefID = plr.CMN_SLS_Pricelist_ReleaseID, IsDeleted = false, Tenant_RefID = securityTicket.TenantID }; var prices = ORM_CMN_SLS_Price.Query.Search(Connection, Transaction, pricelistPriceQry); if (prices.Count == 0) { ORM_CMN_PRO_Product pr = new ORM_CMN_PRO_Product(); pr.Load(Connection, Transaction, item.CMN_PRO_Product_RefID); returnValue.Result.Status_Code = -2; // -2 => pricelist does not have price for product returnValue.Result.Status_Message = pr.Product_Number; return(returnValue); } var newProduct = new ORM_CMN_PRO_Catalog_Product() { CMN_PRO_Catalog_ProductID = Guid.NewGuid(), CMN_PRO_Product_Variant_RefID = item.CMN_PRO_Product_Variant_RefID, Creation_Timestamp = DateTime.Now, Tenant_RefID = item.Tenant_RefID, CMN_PRO_Catalog_Revision_RefID = newRev.CMN_PRO_Catalog_RevisionID, CMN_PRO_Product_RefID = item.CMN_PRO_Product_RefID, }; newProduct.Save(Connection, Transaction); productsMapping.Add(item.CMN_PRO_Catalog_ProductID, newProduct.CMN_PRO_Catalog_ProductID); } #endregion #region ProductGroups var oldGroups = ORM_CMN_PRO_Catalog_ProductGroup.Query.Search(Connection, Transaction, new ORM_CMN_PRO_Catalog_ProductGroup.Query() { Catalog_Revision_RefID = rev.CMN_PRO_Catalog_RevisionID, IsDeleted = false }); //oldGroupID - newGroupID Dictionary <Guid, Guid> groupsMapping = new Dictionary <Guid, Guid>(); groupsMapping.Add(Guid.Empty, Guid.Empty); foreach (var item in oldGroups) { groupsMapping.Add(item.CMN_PRO_Catalog_ProductGroupID, Guid.NewGuid()); } foreach (var item in oldGroups) { var newGroup = new ORM_CMN_PRO_Catalog_ProductGroup() { CMN_PRO_Catalog_ProductGroupID = groupsMapping[item.CMN_PRO_Catalog_ProductGroupID], Catalog_Revision_RefID = newRev.CMN_PRO_Catalog_RevisionID, CatalogProductGroup_Name = item.CatalogProductGroup_Name, CatalogProductGroup_Parent_RefID = groupsMapping[item.CatalogProductGroup_Parent_RefID], Creation_Timestamp = DateTime.Now, Tenant_RefID = item.Tenant_RefID }; newGroup.Save(Connection, Transaction); var oldProductsInGroup = ORM_CMN_PRO_Catalog_Product_2_ProductGroup.Query.Search(Connection, Transaction, new ORM_CMN_PRO_Catalog_Product_2_ProductGroup.Query() { CMN_PRO_Catalog_ProductGroup_RefID = item.CMN_PRO_Catalog_ProductGroupID, IsDeleted = false }); foreach (var product in oldProductsInGroup) { var newProduct = new ORM_CMN_PRO_Catalog_Product_2_ProductGroup() { AssignmentID = Guid.NewGuid(), CMN_PRO_Catalog_ProductGroup_RefID = groupsMapping[product.CMN_PRO_Catalog_ProductGroup_RefID], CMN_PRO_Catalog_Product_RefID = productsMapping[product.CMN_PRO_Catalog_Product_RefID], Creation_Timestamp = DateTime.Now, Tenant_RefID = item.Tenant_RefID }; newProduct.Save(Connection, Transaction); } } #endregion returnValue.Result.Status_Code = 1; returnValue.Result.Status_Message = "Success"; returnValue.Result.ID = newRev.CMN_PRO_Catalog_RevisionID; return(returnValue); #endregion UserCode }
protected static FR_Guid Execute(DbConnection Connection, DbTransaction Transaction, P_L3CA_DIC_1511 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { //Leave UserCode region to enable user code saving #region UserCode var returnValue = new FR_Guid(); var subscribedCatalog = new ORM_CMN_PRO_SubscribedCatalog(); subscribedCatalog.Load(Connection, Transaction, Parameter.SubscribedCatalogID); subscribedCatalog.IsDeleted = true; subscribedCatalog.Save(Connection, Transaction); /* * @all products from this catalog are not available anymore * */ var productQuery = new ORM_CMN_PRO_Product.Query(); productQuery.Tenant_RefID = securityTicket.TenantID; productQuery.IfImportedFromExternalCatalog_CatalogSubscription_RefID = subscribedCatalog.CMN_PRO_SubscribedCatalogID; productQuery.IsDeleted = false; var productList = ORM_CMN_PRO_Product.Query.Search(Connection, Transaction, productQuery).ToList(); foreach (var product in productList) { product.IsProductAvailableForOrdering = false; product.Save(Connection, Transaction); } /* * @delete priceList and all products prices * */ var priceReleaseQuery = new ORM_CMN_SLS_Pricelist_Release.Query(); priceReleaseQuery.Tenant_RefID = securityTicket.TenantID; priceReleaseQuery.CMN_SLS_Pricelist_ReleaseID = subscribedCatalog.SubscribedCatalog_PricelistRelease_RefID; priceReleaseQuery.IsDeleted = false; var priceRelease = ORM_CMN_SLS_Pricelist_Release.Query.Search(Connection, Transaction, priceReleaseQuery).First(); priceRelease.IsDeleted = true; var priceListQuery = new ORM_CMN_SLS_Pricelist.Query(); priceListQuery.Tenant_RefID = securityTicket.TenantID; priceListQuery.CMN_SLS_PricelistID = priceRelease.Pricelist_RefID; priceListQuery.IsDeleted = false; var priceList = ORM_CMN_SLS_Pricelist.Query.Search(Connection, Transaction, priceListQuery).First(); priceList.IsDeleted = true; priceList.Save(Connection, Transaction); var priceQuery = new ORM_CMN_SLS_Price.Query(); priceQuery.Tenant_RefID = securityTicket.TenantID; priceQuery.PricelistRelease_RefID = priceRelease.Pricelist_RefID; priceQuery.IsDeleted = false; var prices = ORM_CMN_SLS_Price.Query.Search(Connection, Transaction, priceQuery).ToList(); foreach (var price in prices) { price.IsDeleted = true; price.Save(Connection, Transaction); } priceRelease.Save(Connection, Transaction); return(returnValue); #endregion UserCode }
protected static FR_Guid Execute(DbConnection Connection, DbTransaction Transaction, P_L5PL_SPfPRaPV_0920 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { #region UserCode var returnValue = new FR_Guid(); //Put your code here foreach (var item in Parameter.Data) { foreach (var currentPrice in item.Prices) { var price = new ORM_CMN_SLS_Price(); price.Tenant_RefID = securityTicket.TenantID; if (currentPrice.PriceAmount == 0 && currentPrice.PriceID != Guid.Empty) { price.Load(Connection, Transaction, currentPrice.PriceID); price.PriceAmount = 0; price.IsDeleted = true; price.Save(Connection, Transaction); } else if (currentPrice.PriceAmount != 0) { if (currentPrice.PriceID != Guid.Empty) { price.Load(Connection, Transaction, currentPrice.PriceID); price.PriceAmount = currentPrice.PriceAmount; price.Save(Connection, Transaction); } else { var pricequery = new ORM_CMN_SLS_Price.Query(); pricequery.CMN_Currency_RefID = currentPrice.CurrencyID; pricequery.CMN_PRO_Product_Variant_RefID = item.ProductVariantID; pricequery.PricelistRelease_RefID = item.PricelistReleaseID; var prices = ORM_CMN_SLS_Price.Query.Search(Connection, Transaction, pricequery); if (prices != null && prices.Count > 0) { price = prices.FirstOrDefault(); price.IsDeleted = false; price.PriceAmount = currentPrice.PriceAmount; price.Save(Connection, Transaction); } else { var productVariant = new CL1_CMN_PRO.ORM_CMN_PRO_Product_Variant(); productVariant.Load(Connection, Transaction, item.ProductVariantID); price.CMN_SLS_PriceID = Guid.NewGuid(); price.CMN_Currency_RefID = currentPrice.CurrencyID; price.CMN_PRO_Product_Variant_RefID = item.ProductVariantID; price.CMN_PRO_Product_RefID = productVariant.CMN_PRO_Product_RefID; price.PricelistRelease_RefID = item.PricelistReleaseID; price.PriceAmount = currentPrice.PriceAmount; price.Save(Connection, Transaction); } } } returnValue.Result = price.CMN_SLS_PriceID; } } return(returnValue); #endregion UserCode }
protected static FR_Guid Execute(DbConnection Connection, DbTransaction Transaction, P_L6DTPG_SCL_1016 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { #region UserCode var returnValue = new FR_Guid(); var item = new ORM_CMN_BPT_InvestedWorkTime_ChargingLevel(); #region Unnecessary if (Parameter.CMN_BPT_InvestedWorkTime_ChargingLevelID != Guid.Empty) { var result = item.Load(Connection, Transaction, Parameter.CMN_BPT_InvestedWorkTime_ChargingLevelID); if (result.Status != FR_Status.Success || item.CMN_BPT_InvestedWorkTime_ChargingLevelID == Guid.Empty) { var error = new FR_Guid(); error.ErrorMessage = "No Such ID"; error.Status = FR_Status.Error_Internal; return(error); } if (Parameter.ChargingLevelName != null) { item.ChangingLevel_Name = Parameter.ChargingLevelName; } item.Save(Connection, Transaction); ORM_CMN_SLS_Price.Query priceQuery = new ORM_CMN_SLS_Price.Query(); priceQuery.Tenant_RefID = securityTicket.TenantID; priceQuery.IsDeleted = false; priceQuery.CMN_PRO_Product_RefID = item.CMN_PRO_Product_RefID; List <ORM_CMN_SLS_Price> prices = ORM_CMN_SLS_Price.Query.Search(Connection, Transaction, priceQuery); if (prices != null && prices.Count == 1) { ORM_CMN_SLS_Price price = prices[0]; price.PriceAmount = Parameter.PricePerMinute; price.CMN_Currency_RefID = Parameter.CurrencyID; price.Save(Connection, Transaction); } } else { var structureHeader = new ORM_DOC_Structure_Header(); structureHeader.Label = "document_header_for_product"; structureHeader.Tenant_RefID = securityTicket.TenantID; var structureStatusSave = structureHeader.Save(Connection, Transaction); ORM_CMN_PRO_Product product = new ORM_CMN_PRO_Product(); product.Product_Name = Parameter.ChargingLevelName; product.Product_DocumentationStructure_RefID = structureHeader.DOC_Structure_HeaderID; product.Product_Number = "product_number"; product.Tenant_RefID = securityTicket.TenantID; product.Save(Connection, Transaction); ORM_CMN_BPT_InvestedWorkTime_ChargingLevel charginglevel = new ORM_CMN_BPT_InvestedWorkTime_ChargingLevel(); charginglevel.ChangingLevel_Name = Parameter.ChargingLevelName; charginglevel.CMN_PRO_Product_RefID = product.CMN_PRO_ProductID; charginglevel.Tenant_RefID = securityTicket.TenantID; charginglevel.Save(Connection, Transaction); ORM_CMN_SLS_Price price = new ORM_CMN_SLS_Price(); price.CMN_Currency_RefID = Parameter.CurrencyID; price.CMN_PRO_Product_RefID = product.CMN_PRO_ProductID; price.PriceAmount = Parameter.PricePerMinute; price.Tenant_RefID = securityTicket.TenantID; price.Save(Connection, Transaction); } #endregion return(returnValue); #endregion UserCode }