Ejemplo n.º 1
0
        public async Task <IActionResult> Add([Bind("TaxOperationId,Name,TaxFunction,TaxWay,DefaultCode,StockTrigger,CostTrigger,BusinessEntityId")] TaxOperation taxOperation, bool continueAdd)
        {
            if (ModelState.IsValid)
            {
                await _taxOperationServices.AddAsync(taxOperation);

                return(continueAdd ? RedirectToAction(nameof(Add)) : RedirectToAction(nameof(List)));
            }
            return(View(taxOperation));
        }
Ejemplo n.º 2
0
 public async Task <IActionResult> Edit(int id, [Bind("TaxOperationId,Name,TaxFunction,TaxWay,DefaultCode,StockTrigger,CostTrigger,BusinessEntityId")] TaxOperation taxOperation, bool continueAdd)
 {
     if (id != taxOperation.TaxOperationId)
     {
         return(NotFound());
     }
     if (ModelState.IsValid)
     {
         try
         {
             await _taxOperationServices.UpdateAsync(taxOperation);
         }
         catch (DbUpdateConcurrencyException)
         {
             throw;
         }
         return(continueAdd ? RedirectToAction(nameof(Edit), new { id = taxOperation.TaxOperationId }) : RedirectToAction(nameof(List)));
     }
     return(View(taxOperation));
 }
Ejemplo n.º 3
0
        static void Main(string[] args)
        {
            Console.WriteLine(" Main function invokded by Primary thread {0}.", Thread.CurrentThread.ManagedThreadId);

            ArithmaticOperqtion opn1 = new ArithmaticOperqtion(Addition);

            TaxController controller = ControllerFactory.CreateInstance();

            // Controller action method registration

            TaxOperation tax1 = new TaxOperation(controller.PayIncomeTax);
            TaxOperation tax2 = new TaxOperation(controller.PaySalesTax);
            TaxOperation tax3 = new TaxOperation(controller.PayServiceTax);


            //perform asynchronous action methods

            IAsyncResult iarTax1 = tax1.BeginInvoke(null, null);
            IAsyncResult iarTax2 = tax2.BeginInvoke(null, null);
            IAsyncResult iarTax3 = tax3.BeginInvoke(null, null);


            //Perform other tasks independent of
            //taxation using primary Thread
            //Listen for incomming requests from client



            while (!iarTax1.AsyncWaitHandle.WaitOne(1000, true))
            {
                Console.WriteLine(".....Get other customer details!");
                Console.WriteLine("Primary thread {0}.", Thread.CurrentThread.ManagedThreadId);
            }

            while (!iarTax2.AsyncWaitHandle.WaitOne(1000, true))
            {
                Console.WriteLine(".....Get other customer details!");
                Console.WriteLine("Primary thread {0}.", Thread.CurrentThread.ManagedThreadId);
            }

            while (!iarTax3.AsyncWaitHandle.WaitOne(1000, true))
            {
                Console.WriteLine(".....Get other customer details!");
                Console.WriteLine("Primary thread {0}.", Thread.CurrentThread.ManagedThreadId);
            }

            tax1.EndInvoke(iarTax1);
            tax2.EndInvoke(iarTax2);
            tax3.EndInvoke(iarTax3);


            Console.WriteLine(" primary thread recieved notification");
            Console.WriteLine(" primary thread now started other work after taxation");

            /*
             *          int op1 = 45;
             *          int op2 = 3;
             *
             *          // int result = opn1(op1, op2);
             *         IAsyncResult iftAR= opn1.BeginInvoke(op1, op2, null, null);
             *
             *          // This message will keep printing until the Add() method is finished.
             *          while (!iftAR.AsyncWaitHandle.WaitOne(1000, true))
             *          {
             *              Console.WriteLine("Doing more work in Main()!");
             *              Console.WriteLine("Primary thread {0}.", Thread.CurrentThread.ManagedThreadId);
             *          }
             *
             *          int result = opn1.EndInvoke(iftAR);
             *          Console.WriteLine(" Result = {0}", result);
             *          Console.WriteLine(result);
             */
            Console.ReadLine();
        }
Ejemplo n.º 4
0
        public IActionResult Add()
        {
            var data = new TaxOperation();

            return(View(data));
        }
Ejemplo n.º 5
0
        public async Task <IActionResult> Delete(TaxOperation taxOperation)
        {
            await _taxOperationServices.DeleteAsync(taxOperation);

            return(RedirectToAction(nameof(List)));
        }