Exemple #1
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            if (!Page.IsValid)
            {
                return;
            }

            MessageUI MessageUI = new MessageUI();

            MessageUI.Description = txtDescription.Text;

            if (IsNewMode)
            {
                List <string> SendTo = new List <string>();
                foreach (ListItem item in ddlSendTo.Items)
                {
                    if (item.Selected)
                    {
                        SendTo.Add(item.Value);
                    }
                }

                MessageId = MessagesController.CreateNewMessage(MessageUI);

                if ((SendTo.Count == 1 && SendTo[0] == "Suppliers") || SendTo.Count == 0 || SendTo.Count == 2)
                {
                    SupplierNotification.SendNotificationNewMessage(MessageUI.Description);
                }
                if ((SendTo.Count == 1 && SendTo[0] == "AppUsers") || SendTo.Count == 0 || SendTo.Count == 2)
                {
                    //  int results = FcmService.SendFcmNotification(MessageUI.Description);
                    // Notification.SendNotificationNewMessageToAllDevices(MessageUI.Description);
                    //var result =  FcmService.SendFcmNotification(MessageUI.Description);
                }
            }

            if (IsNewMode)
            {
                string successMessage = MessagesStrings.GetText(@"MessageMessageCreated");
                string url            = @"EditMessage.aspx?ID=" + MessageId.ToString();
                url += @"&message-success=" + Server.UrlEncode(successMessage);
                Response.Redirect(url, true);
            }
            else
            {
                string successMessage = MessagesStrings.GetText(@"MessageMessageSaved");

                string url = @"EditMessage.aspx?message-success=" + Server.UrlEncode(successMessage);
                url += @"&ID=" + MessageId.ToString();
                Response.Redirect(url, true);
            }
        }