Exemplo n.º 1
0
        public async Task <IActionResult> DivOperation(
            GenericOperation genericOperation,
            [FromServices] DaprClient daprClient)
        {
            Console.WriteLine("Div Request");
            decimal resultOperation = genericOperation.FirstOperand + genericOperation.SecondOperand;

            // Add event to eventSource
            var currentOperation = new Operation()
            {
                OperationData = new GenericOperation()
                {
                    FirstOperand  = genericOperation.FirstOperand,
                    SecondOperand = genericOperation.SecondOperand,
                    Id            = genericOperation.Id
                },
                OperationType = Operation.OperandType.Divide
            };
            await daprClient.PublishEventAsync("Calculator", "CalculatorOperation", currentOperation);

            // Set current state
            var state = await daprClient.GetStateEntryAsync <decimal>(StoreName, genericOperation.Id);

            state.Value = resultOperation;
            await state.SaveAsync();

            // Return Ok to client
            return(Ok());
        }
Exemplo n.º 2
0
        public static GenericOperation CreateOperation(string oprator)
        {
            GenericOperation operation = null;

            switch (oprator)
            {
            case "+":
                operation = new AddOperation();
                break;

            case "-":
                operation = new SubOperation();
                break;

            case "*":
                operation = new MulOperation();
                break;

            case "/":
                operation = new DivOperation();
                break;

            default:
                throw new System.ArgumentException(string.Format("{0} operation is not defined.", oprator));
                // break;
            }
            return(operation);
        }
Exemplo n.º 3
0
        public async Task <IActionResult> ThrowException(GenericOperation genericOperation)
        {
            Console.WriteLine("Enter ThrowException");
            var   task = Task.Delay(10);
            await task;

            return(BadRequest(new { statusCode = 400, message = "bad request" }));
        }
Exemplo n.º 4
0
        public void Add()
        {
            var opi = GenericOperation <int> .GetInstance();

            opi.Add(110, 13).Is(123);

            var opd = GenericOperation <double> .GetInstance();

            opd.Add(1.10, 0.13).Is(1.23);
        }
Exemplo n.º 5
0
 private void btnDalTest_Click(object sender, EventArgs e)
 {
     GenericOperation operation = new GenericOperation();
     DataTable        table     = operation.Query(new QueryEntity
     {
         TableName = "member",
         Columns   = new List <string> {
             "id", "name"
         },
         Condition = new Condition
         {
             Columns = new List <QueryColumn>
             {
                 new QueryColumn("id", OperationTypeEnum.Equals, "1"),
             },
         }
     });
 }
Exemplo n.º 6
0
 public LoginController(IConfiguration config, SportNewsContext sportNewsContext)
 {
     _config               = config;
     this.unitOfWork       = new UnitOfWork(sportNewsContext);
     this.genericOperation = new GenericOperation((UnitOfWork)unitOfWork);
 }