Ejemplo n.º 1
0
        /// <summary>
        /// This is a top level command function.
        /// </summary>
        private async void SendMessage()
        {
            IsSending = true;
            OperationResultArgs CommandResult;
            bool   isError    = true;
            string statusText = string.Empty;

            if (Message.Validate())
            {
                var Result = await WebCommunicator.Post(Message);

                statusText = Message.Status.Text;
                if (Result == HttpStatusCode.OK)
                {
                    isError = false;
                    ClearMessage();
                }
            }
            else
            {
                statusText = "Invalid Message.";
            }

            CommandResult = new OperationResultArgs
            {
                IsError    = isError,
                ResultText = statusText
            };

            _dataRepository.AddMessage(Message);

            RaiseNotification(this, CommandResult);
            IsSending = false;
        }