コード例 #1
0
        public int SendMessageToCustomerForVisit(AppointmentMaster appointmentMaster, string ClientAPIURL, int CreatedBy)
        {
            MySqlCommand cmd         = new MySqlCommand();
            int          resultCount = 0;
            //CustomerChatModel ChatMessageDetails = new CustomerChatModel();
            ClientCustomSendTextModel SendTextRequest = new ClientCustomSendTextModel();
            string ClientAPIResponse = string.Empty;

            try
            {
                string textToReply = "Dear" + appointmentMaster.CustomerName + ",Your Visit for Our Store is schedule On" + appointmentMaster.AppointmentDate +
                                     "On Time Between" + appointmentMaster.TimeSlot;
                #region call client api for sending message to customer

                SendTextRequest.To          = appointmentMaster.MobileNo;
                SendTextRequest.textToReply = textToReply;
                SendTextRequest.programCode = appointmentMaster.ProgramCode;

                string JsonRequest = JsonConvert.SerializeObject(SendTextRequest);

                ClientAPIResponse = CommonService.SendApiRequest(ClientAPIResponse + "api/ChatbotBell/SendText", JsonRequest);


                // response binding pending as no response structure is provided yet from client------

                //--------

                #endregion

                //if (ChatID > 0)
                //{
                //    ChatMessageDetails.ChatID = ChatID;
                //    ChatMessageDetails.Message = Message;
                //    ChatMessageDetails.ByCustomer = false;
                //    ChatMessageDetails.ChatStatus = 1;
                //    ChatMessageDetails.StoreManagerId = CreatedBy;
                //    ChatMessageDetails.CreatedBy = CreatedBy;

                //    resultCount = SaveChatMessages(ChatMessageDetails);

                //}
            }
            catch (Exception)
            {
                throw;
            }

            return(resultCount);
        }
コード例 #2
0
        /// <summary>
        /// send Message To Customer
        /// </summary>
        /// <param name="ChatID"></param>
        /// <param name="MobileNo"></param>
        /// <param name="ProgramCode"></param>
        /// <param name="Messsage"></param>
        /// <param name="ClientAPIURL"></param>
        /// <param name="CreatedBy"></param>
        /// <returns></returns>
        public int SendMessageToCustomer(int ChatID, string MobileNo, string ProgramCode, string Message, string WhatsAppMessage, string ImageURL, string ClientAPIURL, int CreatedBy, int InsertChat)
        {
            MySqlCommand               cmd                    = new MySqlCommand();
            int                        resultCount            = 0;
            CustomerChatModel          ChatMessageDetails     = new CustomerChatModel();
            ClientCustomSendTextModel  SendTextRequest        = new ClientCustomSendTextModel();
            ClientCustomSendImageModel SendImageRequest       = new ClientCustomSendImageModel();
            string                     ClientAPIResponse      = string.Empty;
            string                     ClientImageAPIResponse = string.Empty;

            //bool isMessageSent = false;

            try
            {
                #region call client api for sending message to customer
                if (string.IsNullOrEmpty(ImageURL))
                {
                    SendTextRequest.To          = MobileNo;
                    SendTextRequest.textToReply = Message;
                    SendTextRequest.programCode = ProgramCode;

                    string JsonRequest = JsonConvert.SerializeObject(SendTextRequest);

                    ClientAPIResponse = CommonService.SendApiRequest(ClientAPIURL + "api/ChatbotBell/SendText", JsonRequest);
                }

                if (!string.IsNullOrEmpty(ImageURL))
                {
                    SendImageRequest.To          = MobileNo;
                    SendImageRequest.textToReply = WhatsAppMessage;
                    SendImageRequest.programCode = ProgramCode;
                    SendImageRequest.imageUrl    = ImageURL;

                    string JsonRequests = JsonConvert.SerializeObject(SendImageRequest);

                    ClientImageAPIResponse = CommonService.SendImageApiRequest(ClientAPIURL + "api/ChatbotBell/SendImage", JsonRequests);
                }

                //if (!string.IsNullOrEmpty(ClientAPIResponse))
                //{
                //    isMessageSent = Convert.ToBoolean(ClientAPIResponse);

                //    if (isMessageSent && ChatID > 0 && InsertChat.Equals(1))
                //    {
                //        ChatMessageDetails.ChatID = ChatID;
                //        ChatMessageDetails.Message = Message;
                //        ChatMessageDetails.ByCustomer = false;
                //        ChatMessageDetails.ChatStatus = 1;
                //        ChatMessageDetails.StoreManagerId = CreatedBy;
                //        ChatMessageDetails.CreatedBy = CreatedBy;

                //        resultCount = SaveChatMessages(ChatMessageDetails);

                //    }
                //}

                #endregion
            }
            catch (Exception)
            {
                throw;
            }

            return(resultCount);
        }