Advertisement
Guest User

Untitled

a guest
Aug 12th, 2015
372
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.46 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Net;
  5. using System.Net.Http;
  6. using System.Web.Http;
  7.  
  8. namespace DistCalcRESTService.Controllers
  9. {
  10.     public class Point
  11.     {
  12.         public int X { get; set; }
  13.  
  14.         public int Y { get; set; }
  15.  
  16.         public static double distance(Point startPoint, Point endPoit)
  17.         {
  18.             int deltaX = startPoint.X - endPoit.X;
  19.             int deltaY = startPoint.Y - endPoit.Y;
  20.             return Math.Sqrt(deltaX * deltaX + deltaY * deltaY);
  21.  
  22.         }
  23.  
  24.     }
  25.    
  26.     public class ValuesController : ApiController
  27.     {
  28.         // GET api/values
  29.         public string Get()
  30.         {
  31.             return "a+b";
  32.         }
  33.  
  34.         // GET api/values/5
  35.         [Route("dist")]
  36.         public double distance(int x1, int y1, int x2,int y2)
  37.         {
  38.             Point startPoint = new Point()
  39.             {
  40.                 X = x1,
  41.                 Y = y1
  42.             };
  43.             Point endPoint = new Point()
  44.             {
  45.                 X = x2,
  46.                 Y = y2
  47.             };
  48.  
  49.             return Point.distance(startPoint,endPoint);
  50.         }
  51.  
  52.         // POST api/values
  53.         public void Post([FromBody]string value)
  54.         {
  55.         }
  56.  
  57.         // PUT api/values/5
  58.         public void Put(int id, [FromBody]string value)
  59.         {
  60.         }
  61.  
  62.         // DELETE api/values/5
  63.         public void Delete(int id)
  64.         {
  65.         }
  66.     }
  67. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement