Beispiel #1
0
        private string SaveQuote(string command)
        {
            //Get username and quote from pCommand
            if (command.IndexOf(":", StringComparison.Ordinal) == -1)
            {
                return "Unable to save. Could not find username...";
            }
            
            var username = command.Substring(0, command.IndexOf(":", StringComparison.Ordinal));
            var quote = command.Substring(
                command.IndexOf(":", StringComparison.Ordinal) + 1).Trim();

            var newQuote = new Quote()
                {
                    Username = username,
                    UserQuote = quote
                };

            //Add new quote to list so that it will be included right away
            _mQuoteList.Add(newQuote);
            _mFullQuoteList.Add(newQuote);

            //TODO: Fulfix?
            var sendStatus = new Status();

            //Send it to cloud
            SaveData(newQuote, sendStatus);

            return sendStatus.StatusCode == StatusCode.Ok ? "Successfully added to database." : "Error saving quote to database.";
        }
Beispiel #2
0
 private static async void SaveData(Quote quote, Status status)
 {
     //Create ParseObject for saving in DB
     var parseObject = new ParseObject("Quotes");
     parseObject["Name"] = quote.Username;
     parseObject["Quote"] = quote.UserQuote;
     
     try
     {
         await parseObject.SaveAsync();
         status.StatusCode = StatusCode.Ok;
     }
     catch (Exception)
     {
         Console.WriteLine(@"Error saving quote to database.");
         status.StatusCode = StatusCode.Error;
         throw;
     }
 }