public async Task <IActionResult> DeleteServerOrder([FromQuery] int orderId)
        {
            Debug.WriteLine("Deleting order with id= " + orderId);

            if (!ModelState.IsValid)
            {
                return(BadRequest("Request body is not correct!"));
            }

            using (UnitOfWork unitOfWork = new UnitOfWork(this._databaseContext))
            {
                if (unitOfWork.ServerOrderRepository.Get(orderId) == null)
                {
                    return(BadRequest("Order not exist!"));
                }
                unitOfWork.ServerOrderRepository.Remove(unitOfWork.ServerOrderRepository.Get(orderId));
                await unitOfWork.Save();
            }

            var deletingProvider = new DeletingOrderProvider();

            await deletingProvider.DeleteOrder(orderId);

            return(new JsonResult(orderId));
        }
Пример #2
0
        public static async Task Execute()
        {
            await Task.Delay(30000);

            //initializing new provider for adding order with specific implementation of composers and job.
            var addingProvider = new AddingOrderProvider <
                ServerJobDetailComposer <ServerOrderJob>,
                SimpleTriggerComposer,
                ServerOrderJob>(
                new ServerJobDetailComposer <ServerOrderJob>(1, "172.217.16.14"),
                new SimpleTriggerComposer(5, 1)
                );

            //asynchronous adding order.
            await addingProvider.AddOrder();

            await Task.Delay(15100);

            //deleting order from schedule after delay.
            var deletingProvider = new DeletingOrderProvider();
            await deletingProvider.DeleteOrder(1);

            //adding new provider with implementations for html order
            var addingHtmlProvider = new AddingOrderProvider <
                HtmlJobDetailComposer <HtmlOrderJob>,
                SimpleTriggerComposer,
                HtmlOrderJob>(
                new HtmlJobDetailComposer <HtmlOrderJob>(2, "http://www.nordlearn.com.pl", "1"),
                new SimpleTriggerComposer(5, 2));

            //asynchronous adding order to schedule.
            await addingHtmlProvider.AddOrder();

            await Task.Delay(15100);

            //deleting order from schedule after delay.
            var deletingHtmlProvider = new DeletingOrderProvider();
            await deletingHtmlProvider.DeleteOrder(2);
        }