/// <summary> /// Creates the expression row. /// </summary> /// <param name="expressionDto">The expression dto.</param> /// <returns></returns> public ExpressionDto.ExpressionRow CreateExpressionRow(ref ExpressionDto expressionDto) { PromotionDto.PromotionConditionRow row = null; ExpressionDto.ExpressionRow expressionRow = null; if (_PromotionDto.PromotionCondition.Count == 0) { row = _PromotionDto.PromotionCondition.NewPromotionConditionRow(); row.PromotionId = _PromotionDto.Promotion[0].PromotionId; expressionRow = expressionDto.Expression.NewExpressionRow(); expressionRow.ApplicationId = MarketingConfiguration.Instance.ApplicationId; expressionRow.Category = ExpressionCategory.CategoryKey.Promotion.ToString(); expressionRow.Created = DateTime.UtcNow; } else { row = _PromotionDto.PromotionCondition[0]; expressionDto = ExpressionManager.GetExpressionDto(row.ExpressionId); expressionRow = expressionDto.Expression[0]; } expressionRow.ModifiedBy = Page.User.Identity.Name; expressionRow.Description = _Config.Description; expressionRow.Name = _Config.Type; row.ExpressionId = expressionRow.ExpressionId; if (row.RowState == DataRowState.Detached) { PromotionDto.PromotionCondition.Rows.Add(row); } return(expressionRow); }
/// <summary> /// Processes the table events. /// </summary> /// <param name="promo">The promo.</param> private void ProcessTableEvents(PromotionDto promo) { foreach (GridItem item in _addedItems) { int expressionId = item[_ExpressionIdString] == null ? 0 : Int32.Parse(item[_ExpressionIdString].ToString()); /* * int nodeId = item[_CatalogNodeIdString] == null ? 0 : Int32.Parse(item[_CatalogNodeIdString].ToString()); * int entryId = item[_CatalogEntryIdString] == null ? 0 : Int32.Parse(item[_CatalogEntryIdString].ToString()); * */ string nodeId = item[_CatalogNodeIdString] == null ? String.Empty : item[_CatalogNodeIdString].ToString(); string entryId = item[_CatalogEntryIdString] == null ? String.Empty : item[_CatalogEntryIdString].ToString(); string catalogName = item[_CatalogNameString] == null ? String.Empty : item[_CatalogNameString].ToString(); PromotionDto.PromotionConditionRow row = promo.PromotionCondition.NewPromotionConditionRow(); row.CatalogEntryId = entryId.ToString(); row.CatalogName = catalogName; row.CatalogNodeId = nodeId.ToString(); row.ExpressionId = expressionId; row.PromotionId = promo.Promotion[0].PromotionId; promo.PromotionCondition.Rows.Add(row); } _addedItems.Clear(); foreach (GridItem item in _removedItems) { int id = Int32.Parse(item["PromotionConditionId"].ToString()); // find the existing one foreach (PromotionDto.PromotionConditionRow row in promo.PromotionCondition.Rows) { if (row.PromotionConditionId == id) { row.Delete(); } } } _removedItems.Clear(); }