コード例 #1
0
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            int result = 0;
            Subscriber subsriber = new Subscriber
            {
                EmailAddress = txtEmailAddress.Text,
                IsActive = true,
                CreatedAt = DateTime.Now,
            };
            SubscriberCRUD subscriberCrud = new SubscriberCRUD();
            Subscriber isExists = subscriberCrud.GetList()
                .Where(x => x.EmailAddress == txtEmailAddress.Text)
                .FirstOrDefault();

            if (isExists == null)
            {
                result = subscriberCrud.Add(subsriber);
            }
            else if (!isExists.IsActive)
            {
                isExists.IsActive = !isExists.IsActive;
                subscriberCrud.Update(isExists);
            }

            if (result == -1)
            {
                Response.Redirect("~/Default.aspx?IsSuccess=SubscribeError");
            }
            Response.Redirect("~/Default.aspx?IsSuccess=SubscribeSuccess");
        }
コード例 #2
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (User != null)
     {
         SubscriberCRUD subscriberCrud = new SubscriberCRUD();
         Subscriber subscriber = User;
         if (subscriber.IsActive)
         {
             subscriber.IsActive = false;
             subscriberCrud.Update(subscriber);
         }
         ((UserMaster)Page.Master).ShowSuccess("Повідомлення з нашого сайту не надходитимуть на вашу пошту");
         return;
     }
     ((UserMaster)Page.Master).ShowError("Помилка при відписці. Попробуйте ще раз");
 }
コード例 #3
0
 public void btnSubmit_Click(object sender, EventArgs e)
 {
     Subscriber subscriber = new Subscriber();
     SubscriberCRUD subscriberCrud = new SubscriberCRUD();
     try
     {
         subscriber = new Subscriber()
        {
            Id = PageID,
            EmailAddress = txtEmail.Text,
            IsActive = Convert.ToBoolean(txtIsActive.Text),
            CreatedAt = Convert.ToDateTime(txtCreatedAt.Text),
            UpdatedAt = Convert.ToDateTime(txtUpdatedAt.Text)
        };
     }
     catch (Exception ex)
     {
         ((BeMaster)Page.Master).ShowError(ex.Message);
         return;
     }
     subscriberCrud.Update(subscriber);
     Response.Redirect("~/BE/Subscribers.aspx");
 }