Exemplo n.º 1
0
        public async Task <IWriterResult <int> > CreateSupportTicketReply(string userId, CreateSupportTicketReplyModel model)
        {
            using (var context = DataContextFactory.CreateContext())
            {
                var ticket = await context.SupportTicket.Include(x => x.Replies).FirstOrDefaultNoLockAsync(x => x.Id == model.TicketId);

                if (ticket == null)
                {
                    return(WriterResult <int> .ErrorResult("Support ticket #{0} not found", model.TicketId));
                }

                var reply = new SupportTicketReply
                {
                    Message  = model.Message,
                    UserId   = userId,
                    TicketId = ticket.Id,
                    IsPublic = true,
                    IsAdmin  = false,
                    Created  = DateTime.UtcNow
                };
                ticket.Replies.Add(reply);
                ticket.Status     = SupportTicketStatus.UserReply;
                ticket.LastUpdate = DateTime.UtcNow;
                await context.SaveChangesAsync();

                return(WriterResult <int> .SuccessResult(reply.Id));
            }
        }
        public IEnumerable <SupportTicketReply> GetSupportTicketReply(SupportTicketReply supportTicketReply)
        {
            using (DemsifyEntities dataContext = new DemsifyEntities())
            {
                ObjectParameter totalPageCount = new ObjectParameter("TotalPageCount", typeof(int));
                ObjectParameter totalRecord    = new ObjectParameter("TotalRecord", typeof(int));

                var supportTicketReplys = dataContext.SupportTicketReplyGet(supportTicketReply.SupportTicketId, supportTicketReply.UserId, Utility.TrimString(supportTicketReply.SearchText), supportTicketReply.IsActive, supportTicketReply.PageNumber, supportTicketReply.PageSize, supportTicketReply.IsPagingRequired, Utility.TrimString(supportTicketReply.OrderBy), Utility.TrimString(supportTicketReply.OrderByDirection), totalPageCount, totalRecord).ToList();

                var supportTicketReplyList = new List <SupportTicketReply>();
                foreach (var supportTicketReplyDetail in supportTicketReplys)
                {
                    supportTicketReplyList.Add(new SupportTicketReply()
                    {
                        SupportTicketReplyId = supportTicketReplyDetail.SupportTicketReplyId,
                        UserId          = supportTicketReplyDetail.UserId,
                        SupportTicketId = supportTicketReplyDetail.SupportTicketId,
                        QueryReply      = supportTicketReplyDetail.QueryReply,
                        IsActive        = supportTicketReplyDetail.IsActive,
                        TotalPageCount  = Convert.ToInt32(totalPageCount.Value),
                        TotalRecord     = Convert.ToInt32(totalRecord.Value)
                    });
                }
                return(supportTicketReplyList);
            }
        }
Exemplo n.º 3
0
        private string AddTicketResponseToEmailBody(SupportTicketReply ticket, bool endTag = true)
        {
            var body = string.Empty;

            if (ticket.IsMember)
            {
                body += FromUsername + ":\n";
            }
            else
            {
                body += AppSettings.Site.Name + ":\n";
            }
            body += ticket.Message;

            if (endTag)
            {
                body += "\n\n-------------------------------------\n\n";
            }
            else
            {
                body += "\n\n";
            }

            return(body);
        }
Exemplo n.º 4
0
    protected void SupportTicketButton_Click(object sender, EventArgs e)
    {
        try
        {
            if (Member.IsLogged)
            {
                var ticket = new SupportTicket(Convert.ToInt32(Request.QueryString["ticketId"]));
                var InText = InputChecker.HtmlEncode(SupportTicketTextBox.Text, SupportTicketTextBox.MaxLength, U5004.MESSAGE);

                ticket.ReplyFromMember(InText);
                ticket.IsSolved = false;
                ticket.Date     = DateTime.Now;
                ticket.Save();
                SuccMessage.Text = U3501.SUPPSENT;

                TicketLiteral.Text = SupportTicketReply.GetAllTicketRepliesHtml(ticket.Id, Member.Current, true);

                //Clear the fields
                ErrorMessagePanel.Visible = false;
                SupportTicketTextBox.Text = "";
            }
        }
        catch (MsgException ex)
        {
            ErrorMessagePanel.Visible = true;
            ErrorMessage.Text         = ex.Message;
        }
        catch (Exception ex)
        {
            ErrorLogger.Log(ex);
        }
    }
Exemplo n.º 5
0
    protected void Page_Load(object sender, EventArgs e)
    {
        string IsTicket = string.IsNullOrEmpty(Request.QueryString["ticketId"]) ? "" : Request.QueryString["ticketId"];

        if (IsTicket != "")
        {
            TicketLiteral.Text = SupportTicketReply.GetAllTicketRepliesHtml(Convert.ToInt32(IsTicket), Member.CurrentInCache, true, true);
            NotificationManager.Refresh(NotificationType.UnreadSupportTickets);
        }
    }
Exemplo n.º 6
0
        public void ReplyFromMember(string body)
        {
            var supportReply = new SupportTicketReply();

            supportReply.Message   = body;
            supportReply.TicketId  = this.Id;
            supportReply.ReplyDate = AppSettings.ServerTime;
            supportReply.IsMember  = true;

            supportReply.Save();
        }
        public int DeleteSupportTicketReply(SupportTicketReply supportTicketReply)
        {
            using (DemsifyEntities dataContext = new DemsifyEntities())
            {
                ObjectParameter result = new ObjectParameter("Result", typeof(int));

                dataContext.SupportTicketReplyDelete(supportTicketReply.SupportTicketReplyId, supportTicketReply.ModifiedBy, result);

                return(Convert.ToInt32(result.Value));
            }
        }
Exemplo n.º 8
0
        public IHttpActionResult DeleteSupportTicketReply(DeleteSupportTicketReplyRequest deleteSupportTicketReplyRequest)
        {
            var responses = new Responses();

            try
            {
                if (!ModelState.IsValid)
                {
                    return(BadRequest(ModelState));
                }

                if (Utility.UserId < 0)
                {
                    return(BadRequest(Utility.INVALID_USER));
                }

                var supportTicketReply = new SupportTicketReply()
                {
                    SupportTicketReplyId = deleteSupportTicketReplyRequest.SupportTicketReplyId,
                    ModifiedBy           = Utility.UserId
                };

                int result = iSupportTicketReply.DeleteSupportTicketReply(supportTicketReply);
                switch (result)
                {
                case 1:
                    responses.Status      = Utility.SUCCESS_STATUS_RESPONSE;
                    responses.Description = "Query reply deleted successfully.";
                    break;

                case -2:
                    responses.Status      = Utility.ERROR_STATUS_RESPONSE;
                    responses.Description = "Query reply doesn't exist.";
                    break;

                default:
                    responses.Status      = Utility.ERROR_STATUS_RESPONSE;
                    responses.Description = "Error while deleting query reply.";
                    break;
                }
            }
            catch (Exception ex)
            {
                responses.Status      = Utility.ERROR_STATUS_RESPONSE;
                responses.Description = "Error while deleting query reply.";

                Utility.WriteLog("DeleteSupportTicketReply", deleteSupportTicketReplyRequest, "Error while deleting supportticketreply. (SupportTicketReplyAdminController)", ex.ToString());
            }
            return(Ok(responses));
        }
        public SupportTicketReply AddSupportTicketReply(SupportTicketReply supportTicketReply)
        {
            using (DemsifyEntities dataContext = new DemsifyEntities())
            {
                ObjectParameter result  = new ObjectParameter("Result", typeof(int));
                ObjectParameter emailId = new ObjectParameter("EmailId", typeof(string));

                dataContext.SupportTicketReplyAdd(supportTicketReply.SupportTicketId, supportTicketReply.UserId, Utility.TrimString(supportTicketReply.QueryReply), supportTicketReply.CreatedBy, emailId, result);

                SupportTicketReply objSupportTicketReply = new SupportTicketReply()
                {
                    Result  = Convert.ToInt32(result.Value),
                    EmailId = emailId.Value.ToString()
                };

                return(objSupportTicketReply);
            }
        }
Exemplo n.º 10
0
        public void ReplyFromAdmin(string body, string adminName, bool sendEmail = false)
        {
            var supportReply = new SupportTicketReply();

            supportReply.Message   = body;
            supportReply.TicketId  = this.Id;
            supportReply.ReplyDate = AppSettings.ServerTime;
            supportReply.IsMember  = false;
            supportReply.AdminName = adminName;
            supportReply.Save();

            this.IsRead = false;
            this.Save();

            if (sendEmail)
            {
                sendEmailOnReply();
            }
        }
        public IHttpActionResult GetSupportTicketReply([FromUri] GetSupportTicketReplyRequest getSupportTicketReplyRequest)
        {
            var responses = new Responses();

            try
            {
                if (Utility.UserId < 0)
                {
                    return(BadRequest(Utility.INVALID_USER));
                }

                if (getSupportTicketReplyRequest == null)
                {
                    getSupportTicketReplyRequest = new GetSupportTicketReplyRequest();
                }

                if (getSupportTicketReplyRequest.PageSize == null)
                {
                    getSupportTicketReplyRequest.PageSize = Convert.ToInt32(ConfigurationManager.AppSettings["PageSize"]);
                }

                var supportTicketReply = new SupportTicketReply()
                {
                    SupportTicketId  = getSupportTicketReplyRequest.SupportTicketId,
                    UserId           = getSupportTicketReplyRequest.UserId,
                    SearchText       = getSupportTicketReplyRequest.SearchText,
                    IsActive         = getSupportTicketReplyRequest.IsActive,
                    PageNumber       = getSupportTicketReplyRequest.PageNumber,
                    PageSize         = Convert.ToInt32(getSupportTicketReplyRequest.PageSize),
                    IsPagingRequired = (getSupportTicketReplyRequest.PageNumber != null) ? true : false,
                    OrderBy          = getSupportTicketReplyRequest.OrderBy,
                    OrderByDirection = getSupportTicketReplyRequest.OrderByDirection
                };
                var supportTicketReplies = iSupportTicketReply.GetSupportTicketReply(supportTicketReply);

                var supportTicketReplyList = new List <GetSupportTicketReplyResponse>();
                foreach (var supportTicketReplyDetail in supportTicketReplies)
                {
                    supportTicketReplyList.Add(new GetSupportTicketReplyResponse()
                    {
                        SupportTicketReplyId = supportTicketReplyDetail.SupportTicketReplyId,
                        UserId          = supportTicketReplyDetail.UserId,
                        CurrentUserId   = Utility.UserId,
                        SupportTicketId = supportTicketReplyDetail.SupportTicketId,
                        QueryReply      = supportTicketReplyDetail.QueryReply,
                        IsActive        = Convert.ToBoolean(supportTicketReplyDetail.IsActive),
                        CreatedBy       = supportTicketReplyDetail.CreatedBy,
                        TotalPageCount  = supportTicketReplyDetail.TotalPageCount,
                        TotalRecord     = supportTicketReplyDetail.TotalRecord
                    });
                }

                responses.Status      = Utility.SUCCESS_STATUS_RESPONSE;
                responses.Description = "Query reply retrieved successfully";
                responses.Response    = supportTicketReplyList;
            }
            catch (Exception ex)
            {
                responses.Status      = Utility.ERROR_STATUS_RESPONSE;
                responses.Description = "Error while retrieving query reply.";

                Utility.WriteLog("GetSupportTicketReply", getSupportTicketReplyRequest, "Error while retrieving supportticketreply. (SupportTicketReplyUserController)", ex.ToString());
            }
            return(Ok(responses));
        }
        public IHttpActionResult AddSupportTicketReply(AddSupportTicketReplyRequest addSupportTicketReplyRequest)
        {
            var responses = new Responses();

            try
            {
                if (!ModelState.IsValid)
                {
                    return(BadRequest(ModelState));
                }

                var supportTicketReply = new SupportTicketReply()
                {
                    SupportTicketId = addSupportTicketReplyRequest.SupportTicketId,
                    UserId          = Utility.UserId,
                    QueryReply      = addSupportTicketReplyRequest.QueryReply,
                    CreatedBy       = Utility.UserId
                };
                SupportTicketReply objSupportTicketReply = iSupportTicketReply.AddSupportTicketReply(supportTicketReply);
                if (objSupportTicketReply.Result > 0)
                {
                    var supportTicketEmailHtmlCode = System.IO.File.ReadAllText(string.Format("{0}", HttpContext.Current.Server.MapPath(string.Format("{0}{1}", ConfigurationManager.AppSettings["EmailTemplatePath"], ConfigurationManager.AppSettings["SupportTicketReplyForUserEmailTemplate"]))));

                    var mainTemplateHtmlCode = System.IO.File.ReadAllText(string.Format("{0}", HttpContext.Current.Server.MapPath(string.Format("{0}{1}", ConfigurationManager.AppSettings["EmailTemplatePath"], ConfigurationManager.AppSettings["MainEmailTemplate"]))));
                    mainTemplateHtmlCode = mainTemplateHtmlCode.Replace("[SITEURL]", ConfigurationManager.AppSettings["SiteUrl"]);
                    mainTemplateHtmlCode = mainTemplateHtmlCode.Replace("[SITENAME]", ConfigurationManager.AppSettings["SiteName"]);
                    mainTemplateHtmlCode = mainTemplateHtmlCode.Replace("[PAGECONTENT]", supportTicketEmailHtmlCode);

                    string subject     = "Post Query Reply | Demystify Fema";
                    string body        = mainTemplateHtmlCode;
                    string displayName = ConfigurationManager.AppSettings["SiteName"];
                    bool   isSentMail  = Utility.SendMail(ConfigurationManager.AppSettings["AdminEmailId"], string.Empty, string.Empty, subject, body, displayName, string.Empty, true);

                    try
                    {
                        var objSupportTicketReplyMailSent = new SupportTicketReply()
                        {
                            SupportTicketReplyId = objSupportTicketReply.Result,
                            IsMailSentToAdmin    = isSentMail,
                            ModifiedBy           = Utility.UserId
                        };
                        iSupportTicketReply.UpdateSupportTicketReplyMailSent(objSupportTicketReplyMailSent);
                    }
                    catch (Exception ex)
                    {
                        Utility.WriteLog("AddSupportTicketReply", addSupportTicketReplyRequest, "Error while update supportticketreply mailsent. (SupportTicketReplyUserController)", ex.ToString());
                    }

                    responses.Status      = Utility.SUCCESS_STATUS_RESPONSE;
                    responses.Description = "Query reply added successfully.";
                }
                else
                {
                    responses.Status      = Utility.ERROR_STATUS_RESPONSE;
                    responses.Description = "Error while adding query reply.";
                }
            }
            catch (Exception ex)
            {
                responses.Status      = Utility.ERROR_STATUS_RESPONSE;
                responses.Description = "Error while adding query reply.";

                Utility.WriteLog("AddSupportTicketReply", addSupportTicketReplyRequest, "Error while adding supportticketreply. (SupportTicketReplyUserController)", ex.ToString());
            }
            return(Ok(responses));
        }