Ejemplo n.º 1
0
        /// <summary>
        /// Se encarga de persistir los datos.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void PerformAnswer(object sender, EventArgs e)
        {
            try
            {
                //Una implementación no muy buena
                int id = Convert.ToInt32(SessionUtilHelper.GetIdFromSession(Session));
                ItemCommentManager itemCommentManager = new ItemCommentManager();
                ItemComment        itemommentRef      = itemCommentManager.Get(id);

                ItemComment itemComment = new ItemComment();
                itemComment.Resource          = itemommentRef.Resource;
                itemComment.SentenceReference = itemommentRef;
                UCFormInquiry.PopulateModel(itemComment);

                bool success = itemCommentManager.Save(itemComment);

                if (!success && itemCommentManager.HasErrors)
                {
                    Alert.Show("Error", itemCommentManager.ErrorDescription);
                }
                else
                {
                    LoadGridView();
                }
            } catch (Exception exception)
            {
                Alert.Show("Excepción", exception.Message);
            }
            SessionUtilHelper.FlushId(Session);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Muestra el formulario para realizar responder la pregunta.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected override void PerformGenericAction(object sender, UbiquicityEventArg e)
        {
            int id = Convert.ToInt32(e.TheObject.ToString());
            ItemCommentManager itemCommentManager = new ItemCommentManager();
            ItemComment        itemComment        = itemCommentManager.Get(id);

            if (itemComment == null && itemCommentManager.HasErrors)
            {
                Alert.ShowUP("Error", itemCommentManager.ErrorDescription);
            }
            else
            {
                //Si existe la referencia, entonces a sido respondida
                if (itemComment.SentenceReference == null)
                {
                    UCFormInquiry.CleanForm();
                    UCFormInquiry.FillForm(itemComment);
                    SessionUtilHelper.KeepInSession(id.ToString(), Session);
                    ScriptManager.RegisterStartupScript(upUCModalForm, upUCModalForm.GetType(), "openModalCreate", "$('#modalInquiry').modal('show');", true);
                    upUCModalForm.Update();
                }
                else
                {
                    Alert.ShowUP("Respuesta", "Esta pregunta ya ha sido respondida; no hay acciones disponibles.");
                }
            }
        }