/// <summary>
        /// This is the main entry point for your service replica.
        /// This method executes when this replica of your service becomes primary and has write status.
        /// </summary>
        /// <param name="cancellationToken">Canceled when Service Fabric needs to shut down this service replica.</param>
        protected override async Task RunAsync(CancellationToken cancellationToken)
        {
            _quoteRepository = new QuoteRepository(this.StateManager);
            await _quoteRepository.AddQuoteAsync(new Quote(Guid.NewGuid(), "I will be. As soon as I have time."));

            await _quoteRepository.AddQuoteAsync(new Quote(Guid.NewGuid(), "But you are resilient"));

            var quotes = await _quoteRepository.GetQuotesAsync();
        }
Exemple #2
0
        public async Task <IActionResult> AddQuote([FromBody] QuoteModel quote)
        {
            try
            {
                var quoteId = await _quotesRepository.AddQuoteAsync(quote);

                return(Ok(quoteId));
            }
            catch (Exception e)
            {
                _logger.LogError($"Não foi possivel adicionar quote: {e}");
                return(BadRequest());
            }
        }
Exemple #3
0
        public async Task AddQuoteAsync([Remainder] string quoteBody)
        {
            if (Context.User is IGuildUser guildUser)
            {
                await _quoteRepository.AddQuoteAsync(new Quote
                {
                    Author  = guildUser,
                    Content = quoteBody
                }, Context.Guild).ConfigureAwait(false);

                _logger.LogInformation("Added quote from {User} in {Guild}", Context.User.Username, Context.Guild.Name);
                await ReplyAsync("Done!").ConfigureAwait(false);
            }
        }