Example #1
0
        /// <summary>
        /// Ajecuta la suscripción
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnSuscription_Click(object sender, EventArgs e)
        {
            try
            {
                //La estrategia consta de concatenar con @ los ids de las categorías para poder guardarlas un campo
                string categoryIds = "";
                foreach (ListItem item in checkCategory.Items)
                {
                    categoryIds += item.Selected ? item.Value + "@" : "";
                }

                NewsAddresseeManager manager   = new NewsAddresseeManager();
                NewsAddressee        addressee = new NewsAddressee();

                //TODO - deberían solicitarse mail y comprobación?
                addressee.Name  = nameSuscriptorInput.Value;
                addressee.Email = mailSuscriptorInput.Value;

                if (!String.IsNullOrEmpty(categoryIds))
                {
                    addressee.Categories = categoryIds.Substring(0, categoryIds.Length - 1);
                }

                bool success = manager.Suscribe(addressee);

                if (!success && manager.HasErrors)
                {
                    Alert.Show("Exception", manager.ErrorDescription);
                }
                else
                {
                    Alert.Show("Registro", "¡El registro fue un éxito! te enviamos un mail para recordarte sobre esto.");
                }
            }
            catch (Exception exception)
            {
                Alert.Show("Exception", exception.Message);
            }
        }
        protected void PerformUnsuscribe(object sender, EventArgs e)
        {
            try
            {
                NewsAddresseeManager naManager     = new NewsAddresseeManager();
                NewsAddressee        newsAddressee = new NewsAddressee();
                newsAddressee.Email = mailInput.Value;

                bool success = naManager.Unsuscribe(newsAddressee, chkConfirm.Checked);
                if (!success && naManager.HasErrors)
                {
                    ((front)Master).Alert.Show("Error", naManager.ErrorDescription);
                }
                else
                {
                    divForm.Visible           = false;
                    divSuccessMessage.Visible = true;
                }
            } catch (Exception exception)
            {
                ((front)Master).Alert.Show("Excepción", exception.Message);
            }
        }