Exemple #1
0
        public async Task UpdateAsync(int id, InputBook bookToUpdate)
        {
            var selectedBook = await DbContext.Books.FindAsync(id);

            if (selectedBook != null)
            {
                // Update Something

                await DbContext.SaveChangesAsync();
            }
        }
        public async Task Create(InputBook book)
        {
            var bookToAdd = new Book
            {
                PagesCount       = book.PagesCount,
                ShortDescription = book.ShortDescription,
                Title            = book.Title
            };
            await DbContext.AddAsync(bookToAdd);

            var result = await DbContext.SaveChangesAsync();

            if (result > 0)
            {
                await EsService.Bulk(bookToAdd);
            }
        }
Exemple #3
0
        public async Task <int> CreateAsync(InputBook book)
        {
            var bookToAdd = new Book
            {
                PagesCount       = book.PagesCount,
                ShortDescription = book.ShortDescription,
                Title            = book.Title
            };
            await DbContext.AddAsync(bookToAdd);

            var result = await DbContext.SaveChangesAsync();

            if (result > 0)
            {
                BgJobs.Enqueue(() => Console.WriteLine("First Background Job"));
            }
            return(bookToAdd.Id); // just for test, we return id;
        }
Exemple #4
0
        public async Task <IActionResult> Create(InputBook book)
        {
            var createdId = await _bookService.CreateAsync(book);

            backgroundJob.Schedule <IEmailService>(emailService => emailService.SendEmail(createdId), TimeSpan.FromMinutes(1));

            backgroundJob.Enqueue(() => _bookService.UpdateAsync(createdId, new InputBook {  /* put some data to update book */
            }));

            //backgroundJob.Enqueue<IBookService>(b => b.UpdateAsync(createdId, new InputBook {  /* put some data to update book */}));


            //var jobId = backgroundJob.Enqueue<IBookService>(b => b.UpdateAsync(createdId, new InputBook {  /* put some data to update book */}));
            //var condition = true;
            //if (condition)
            //{
            //    //change Status
            //    backgroundJob.ChangeState(jobId, new Hangfire.States.DeletedState() { Reason = "some reason" });
            //    //Delete
            //    backgroundJob.Delete(jobId);
            //}

            return(RedirectToAction("Index", "Home"));
        }
Exemple #5
0
        public async Task <IActionResult> Create(InputBook book)
        {
            await BookService.Create(book);

            return(RedirectToAction("Index", "Home"));
        }