Пример #1
0
        public JsonResult BillingMessage(int CntMsgClientID, string CntMsgClientName, int CntMsgClientContactID,
                                         string CntMsgMessageSubject, string CntMsgMessageFromName, string CntMsgMessageBody, string CntMsgMessageToName,
                                         string CntMsgMessageFromEmail, string CntMsgMessageToEmail, string CntMsgMessageCategory, string CntMsgMessageFromPhone)
        {
            BillingMessage_Details viewBillingMessageDetails = new BillingMessage_Details();

            viewBillingMessageDetails.CntMsgClientID         = CntMsgClientID;
            viewBillingMessageDetails.CntMsgClientName       = CntMsgClientName;
            viewBillingMessageDetails.CntMsgClientContactID  = CntMsgClientContactID;
            viewBillingMessageDetails.CntMsgMessageSubject   = CntMsgMessageSubject;
            viewBillingMessageDetails.CntMsgMessageFromName  = CntMsgMessageFromName;
            viewBillingMessageDetails.CntMsgMessageBody      = CntMsgMessageBody;
            viewBillingMessageDetails.CntMsgMessageToName    = CntMsgMessageToName;
            viewBillingMessageDetails.CntMsgMessageFromEmail = CntMsgMessageFromEmail;
            viewBillingMessageDetails.CntMsgMessageToEmail   = CntMsgMessageToEmail;
            viewBillingMessageDetails.CntMsgMessageCategory  = CntMsgMessageCategory;
            viewBillingMessageDetails.CntMsgMessageFromPhone = CntMsgMessageFromPhone;

            ClientContact userresult = ClientContacts.GetClientContactFromClientContactID(CntMsgClientContactID);

            Dictionary <string, string> messagevalues = new Dictionary <string, string>();

            messagevalues.Add("[[COMPANYNAME]]", CntMsgClientName);
            messagevalues.Add("[[USERNAME]]", CntMsgMessageFromName);
            messagevalues.Add("[[USEREMAIL]]", CntMsgMessageFromEmail);
            messagevalues.Add("[[MESSAGECATEGORY]]", CntMsgMessageCategory);
            messagevalues.Add("[[USERPHONE]]", CntMsgMessageFromPhone);
            messagevalues.Add("[[MESSAGEBODY]]", CntMsgMessageBody);
            messagevalues.Add("[[CORPORATENAME]]", System.Configuration.ConfigurationManager.AppSettings["CompanyName"]);

            string subject = "Billing Client Request: " + CntMsgMessageSubject;

            MailGun.SendEmailToEmailAddressFromTemplate(4, 0, "Client Request", 0, ConfigurationManager.AppSettings["supportemail"], subject, "Tech Support", messagevalues);

            return(new JsonResult {
                Data = new { success = true }
            });

            /*var messageRecord = Messages.GetMessageTemplateRecord(0, "Client Request", messagevalues);
             *
             * string messagebody = messageRecord != null ? messageRecord.MessageText : null;
             *
             * if (messagebody != null)
             * {
             *  int messageActionType = messageRecord.MessageActionTypeID.GetValueOrDefault();
             *  int? MessageIDOutput = new int?();
             *  Guid? MessageActionGuidOutput = new Guid?();
             *  subject = "Billing Client Request: " + CntMsgMessageSubject;
             *  Messages.CreateMessageWithAction(messageActionType, subject, messagebody, 2, 1, 0, 3, "", System.DateTime.Now, null, "HTML", ref MessageIDOutput, ref MessageActionGuidOutput);
             *  Messages.UpdateMessageAndMarkForSending(MessageIDOutput.Value, subject, messagebody);
             *  return new JsonResult { Data = new { success = true } };
             * }
             * else
             * {
             *  ModelState.AddModelError("ErrorMessages", "The message body was empty and could not be delivered. Please enter some information in the Message body and try again.");
             *  return new JsonResult
             *  {
             *      Data = new
             *      {
             *          success = false,
             *          view = RenderToString.RenderViewToString(this, "BillingMessage", viewBillingMessageDetails)
             *      }
             *  };
             * }*/
        }