Ejemplo n.º 1
0
        /// <summary>
        /// Binds the form.
        /// </summary>
        private void BindForm()
        {
            // Bind segments
            TargetSegments.DataSource = SegmentManager.GetSegmentDto();
            TargetSegments.DataBind();

            if (_campaign != null)
            {
                //first check permissions
                //if permissions not present, deny
                SecurityManager.CheckRolePermission("marketing:campaigns:mng:edit");

                CampaignDto.CampaignRow row = _campaign.Campaign[0];
                CampaignName.Text        = row.Name;
                this.AvailableFrom.Value = ManagementHelper.GetUserDateTime(row.StartDate);
                this.ExpiresOn.Value     = ManagementHelper.GetUserDateTime(row.EndDate);
                IsActive.IsSelected      = row.IsActive;
                IsArchived.IsSelected    = row.IsArchived;
                Comments.Text            = row.Comments;

                foreach (CampaignDto.CampaignSegmentRow segmentRow in row.GetCampaignSegmentRows())
                {
                    ManagementHelper.SelectListItem(TargetSegments, segmentRow.SegmentId.ToString(), false);
                }
            }
            else
            {
                //first check permissions
                //if permissions not present, deny
                SecurityManager.CheckRolePermission("marketing:campaigns:mng:create");

                this.AvailableFrom.Value = ManagementHelper.GetUserDateTimeNow();
                this.ExpiresOn.Value     = ManagementHelper.GetUserDateTimeNow().AddMonths(1);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Saves the changes.
        /// </summary>
        /// <param name="context">The context.</param>
        public void SaveChanges(IDictionary context)
        {
            CampaignDto dto = (CampaignDto)context[_CampaignDtoString];

            CampaignDto.CampaignRow row = null;

            if (dto.Campaign.Count > 0)
            {
                row            = dto.Campaign[0];
                row.Modified   = DateTime.UtcNow;
                row.ModifiedBy = Page.User.Identity.Name;
            }
            else
            {
                row = dto.Campaign.NewCampaignRow();
                row.ApplicationId = MarketingConfiguration.Instance.ApplicationId;
                row.Created       = DateTime.UtcNow;
                row.ModifiedBy    = Page.User.Identity.Name;
            }

            row.Name       = CampaignName.Text;
            row.StartDate  = this.AvailableFrom.Value.ToUniversalTime();
            row.EndDate    = this.ExpiresOn.Value.ToUniversalTime();
            row.IsActive   = IsActive.IsSelected;
            row.IsArchived = IsArchived.IsSelected;
            row.Comments   = Comments.Text;

            if (row.RowState == DataRowState.Detached)
            {
                dto.Campaign.Rows.Add(row);
            }

            // Attach segments
            // Clear existing segments
            if (dto.CampaignSegment.Count > 0)
            {
                foreach (CampaignDto.CampaignSegmentRow segmentrow in dto.CampaignSegment.Rows)
                {
                    segmentrow.Delete();
                }
            }

            // Attach selected ones
            foreach (ListItem item in TargetSegments.Items)
            {
                if (!item.Selected)
                {
                    continue;
                }

                CampaignDto.CampaignSegmentRow srow = dto.CampaignSegment.NewCampaignSegmentRow();;
                srow.CampaignId = row.CampaignId;
                srow.SegmentId  = Int32.Parse(item.Value);
                dto.CampaignSegment.Rows.Add(srow);
            }
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Creates a new language specific promotion.
 /// </summary>
 /// <param name="promotionLanguageRow">The language specific data.</param>
 /// <param name="promotionRow">The promotion specific data.</param>
 /// <param name="campaignRow">The campaign specific data.</param>
 public Promotion(PromotionDto.PromotionLanguageRow promotionLanguageRow, PromotionDto.PromotionRow promotionRow, CampaignDto.CampaignRow campaignRow)
 {
     if (promotionLanguageRow == null)
     {
         throw new ArgumentNullException("promotionLanguageRow");
     }
     if (promotionRow == null)
     {
         throw new ArgumentNullException("promotionRow");
     }
     if (campaignRow == null)
     {
         throw new ArgumentNullException("campaignRow");
     }
     PromotionLanguageRow = promotionLanguageRow;
     PromotionRow         = promotionRow;
     CampaignRow          = campaignRow;
 }