The phrasing of my question may be flawed but please know that I am new to C# and REST and I only have experience writing basic scripts.
My goal is to create a service that allows a client to consume it and access basic arithmetic functions.
My logic (which is probably wrong) is: Create a class called Sum (or whatever the operation is), implement the class on the Controller within an HTTP Post method and return the expected value to the client. Is this correct?
Here is the simple sum class:
public class Sum { public double value1 { get; set;} public double value2 { get; set;} public double Process(double value1, double value2) { double result = value1 + value2; return result; } } Here is the controller method which gives me an error because it cannot convert the double variable to IHTTPActionResult.
public class CalculatorController : ApiController { public IHttpActionResult Post(double val1, double val2) { Sum sum = null; sum.value1 = val1; sum.value2 = val2; double result = sum.Procesar(val1, val2); return result; } } Based on my brief experience I cannot think on a different way to implement the class on the Controller method, is there any better way to accomplish my goal? References to other sites and documentation are appreciated as well.
Thank you.