Пример #1
0
        public async Task Execute(PerformContext context)
        {
            _logger.HangfireContext = context;

            _logger.LogDebug("Starting job...");

            var prefixes = new string[] { "Fugg", "Dog", "Cheek", "Moo", "Bob", "Choo", "Zee", "Wagh", "Chomp" };
            var suffixes = new string[] { "ed", "er", "ington", "ssssss", "oes", "choo", "lah", "gh", "alot" };

            var name = $"{prefixes[_random.Next(prefixes.Length)]}{suffixes[_random.Next(suffixes.Length)]}";

            var item = new Widget()
            {
                Name        = name,
                Processing  = true,
                DateCreated = DateTime.Now
            };

            _logger.LogDebug("Creating Widget #{0} {1}...", item.Id, item.Name);

            for (int i = 0; i < 10; i++)
            {
                _logger.LogDebug("Thinking...");
                Thread.Sleep(1000);
            }

            var widget = await _service.CreateAsync(item);

            _logger.LogDebug("Created Widget #{0} {1}", widget.Id, widget.Name);

            context.WriteLine("");
        }
Пример #2
0
 public async Task <Widget> Post([FromBody] Widget item)
 {
     return(await _service.CreateAsync(item));
 }