public bool Save(InvoiceItemSupport invoiceItemSupport)
        {
            if (!IsValid(invoiceItemSupport.Comments[0]))
            {
                return(false);
            }

            ItemCommentSupportMapper itemCommentSupportMapper = new ItemCommentSupportMapper();

            if (!itemCommentSupportMapper.Save(invoiceItemSupport))
            {
                string errorDescription = "No se ha podido guardar el comentario de soporte para el id de producto " + invoiceItemSupport.InvoiceItem.Id + ".";
                log.AddLogCritical("Save", errorDescription, this);
                AddError(new ResultBE(ResultBE.Type.FAIL, errorDescription));
                return(false);
            }

            if (!itemCommentSupportMapper.ChangeTopicStatus(invoiceItemSupport.InvoiceItem.Id, false))
            {
                string errorDescription = "No se ha podido cerrar la consulta de soporte para el invoiceItemId" + invoiceItemSupport.InvoiceItem.Id + ".";
                log.AddLogCritical("Save", errorDescription, this);
                AddError(new ResultBE(ResultBE.Type.FAIL, errorDescription));
                return(false);
            }

            return(true);
        }
Beispiel #2
0
        /// <summary>
        /// Crea un comentario.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void PerformComment(object sender, EventArgs e)
        {
            try
            {
                int invoiceItemId = Convert.ToInt32(SessionUtilHelper.GetIdFromSession(Session));

                ItemCommentSupportManager commentManager     = new ItemCommentSupportManager();
                InvoiceItemSupport        invoiceItemSupport = new InvoiceItemSupport();

                invoiceItemSupport.InvoiceItem.Id = invoiceItemId;
                ItemCommentSupport itemCommentSupport = new ItemCommentSupport();

                itemCommentSupport.Sentence   = commentInput.InnerText;
                itemCommentSupport.User       = SessionHelper.GetUser();
                itemCommentSupport.IsOperator = false;
                itemCommentSupport.Date       = DateTime.Now;
                invoiceItemSupport.Comments.Add(itemCommentSupport);

                commentManager.Save(invoiceItemSupport);
                LoadCommentsSupport(invoiceItemId);
            }
            catch (Exception exception)
            {
                //TODO - agregar control de error
                //((front)Master).Alert.Show("Exception", exception.Message);
            }
        }
        /// <summary>
        /// Recupera los comentarios asociados a un producto.
        /// </summary>
        /// <param name="resourceId"></param>
        /// <returns></returns>
        public InvoiceItemSupport GetByInoiceItem(int invoiceItemId)
        {
            UserManager              userManager              = new UserManager();
            InvoiceItemSupport       invoiceItemSupport       = new InvoiceItemSupport();
            InvoiceItemMapper        invoiceItemMapper        = new InvoiceItemMapper();
            ItemCommentSupportMapper itemCommentSupportMapper = new ItemCommentSupportMapper();

            InvoiceItem invoiceItem = invoiceItemMapper.Get(invoiceItemId);

            if (invoiceItem == null)
            {
                string errorDescription = "No se ha podido recuperar el artículo comprado con id " + invoiceItemId + ".";
                log.AddLogCritical("GetByInoiceItem", errorDescription, this);
                AddError(new ResultBE(ResultBE.Type.NULL, errorDescription));
                return(null);
            }

            List <ItemCommentSupport> comments = itemCommentSupportMapper.GetByInvoiceItem(invoiceItemId);

            if (comments != null)
            {
                foreach (ItemCommentSupport comment in comments)
                {
                    comment.User = userManager.Get(comment.User.Id);
                }
            }

            invoiceItemSupport.InvoiceItem = invoiceItem;
            invoiceItemSupport.Comments    = comments;

            return(invoiceItemSupport);
        }
        public bool Save(InvoiceItemSupport invoiceItemSupport)
        {
            ItemCommentSupport itemCommentSupport = invoiceItemSupport.Comments[0];

            base.Save(itemCommentSupport);

            Dal       dal   = new Dal();
            Hashtable table = new Hashtable();

            table.Add("@messageId", itemCommentSupport.Id);
            table.Add("@isOperator", itemCommentSupport.IsOperator);
            table.Add("@invoiceItemId", invoiceItemSupport.InvoiceItem.Id);

            return(dal.Write(table, "spWriteItemCommentSupport") > 0);
        }