public IHttpActionResult Add(int intA, int intB)
        {
            if (!ModelState.IsValid)
            {
                Logger.Error(BadRequest());
                return(BadRequest());
            }

            Call call = new Call
            {
                Insert_date = DateTime.Now
            };

            db.Calls.Add(call);
            try
            {
                db.SaveChanges();
            }
            catch (Exception e)
            {
                Logger.Error(e);
            }

            CallSteps step = new CallSteps()
            {
                ParentId    = call.Id,
                Insert_date = DateTime.Now,
                Value       = DateTime.Now.ToString("dd.MM HH:mm:ss") + " - Call " + call.Id + ". Request to JSON"
            };

            Logger.Info(step.Value);

            db.CallSteps.Add(step);

            step             = new CallSteps();
            step.ParentId    = call.Id;
            step.Insert_date = DateTime.Now;
            step.Value       = step.Insert_date.ToString("dd.MM HH:mm:ss") + " - Call " + call.Id + ". Request to SOAP";
            db.CallSteps.Add(step);
            Logger.Info(step.Value);
            int res = 0;

            CalculatorSoapClient calc = new CalculatorSoapClient();

            step             = new CallSteps();
            step.ParentId    = call.Id;
            step.Insert_date = DateTime.Now;
            step.Value       = step.Insert_date.ToString("dd.MM HH:mm:ss") + " - Call Id : " + call.Id + ". Response from SOAP";
            db.CallSteps.Add(step);
            Logger.Info(step.Value);
            try
            {
                res = calc.Add(intA, intB);
                db.SaveChanges();
            }
            catch (Exception e)
            {
                Logger.Error(e.Message);
            }

            return(Json(res));
        }
示例#2
0
 public int Add(int a, int b)
 {
     return(calculatr.Add(a, b));
 }