public ActionResult <double> Post([FromBody] ArgumentsModel model)
        {
            double?result = null;

            if (model == null)
            {
                return(BadRequest("Неверно указаны аргументы"));
            }

            switch (model.Operation)
            {
            case "sum":
                result = CalculatorFunctions.Sum(model.FirstDigit, model.SecondDigit);
                break;

            case "multiply":
                result = CalculatorFunctions.Multiply(model.FirstDigit, model.SecondDigit);
                break;

            //TODO: Добавление новых операций
            default:
                return(BadRequest("Неправильно указана операция"));
            }

            return(result);
        }
 private void buttonValidate_Click(object sender, EventArgs e)
 {
     if (CalculatorFunctions.ValidCIDR(textBoxValidate.Text))
     {
         validationLabel.Text = "OK";
     }
     else
     {
         validationLabel.Text = "BAD";
     }
 }
 private void buttonRange_Click(object sender, EventArgs e)
 {
     if (CalculatorFunctions.ValidCIDR(textBoxRange.Text))
     {
         string[] addressRange = CalculatorFunctions.CalculateCIDRRange(textBoxRange.Text).Split(':');
         cidrRangeLowLabel.Text  = addressRange[0];
         cidrRangeHighLabel.Text = addressRange[1];
     }
     else
     {
         cidrRangeLowLabel.Text  = "BAD CIDR.";
         cidrRangeHighLabel.Text = "BAD CIDR.";
     }
 }
 private void buttonOverlap_Click(object sender, EventArgs e)
 {
     if (CalculatorFunctions.ValidCIDR(textBoxOverlapNet1.Text) && CalculatorFunctions.ValidCIDR(textBoxOverlapNet2.Text))
     {
         if (CalculatorFunctions.CIDROverlaps(textBoxOverlapNet1.Text, textBoxOverlapNet2.Text))
         {
             labelOverlap.Text = "OVERLAP";
         }
         else
         {
             labelOverlap.Text = "NO OVERLAP";
         }
     }
     else
     {
         labelOverlap.Text = "BAD CIDR";
     }
 }
Exemplo n.º 5
0
 static void Main(string[] args)
 {
     Console.WriteLine(CalculatorFunctions.add(1, 2));
     Console.ReadKey();
 }