using System using System Collections using System Collections Generic

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
using System;
using System.Collections;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Security.Cryptography;
using System.Security.Policy;
using System.Text;
using System.Web;
using System.Web.Helpers;
using System.Web.Http;
using HtmlAgilityPack;
using ObedServer.Models;
using Newtonsoft.Json;
namespace ObedServer.Controllers
{
public class MenuController : ApiController
{
private const string Url = "http://www.obedtula.ru";
// GET api/menu/5
public IList<Dish> Get(int id)
{
HtmlDocument document = new HtmlDocument();
string remoteURL = Url + "/menu/" + id + "/";
using (WebClient client = new WebClient())
{
client.Encoding = Encoding.GetEncoding(1251);
document.LoadHtml(client.DownloadString(remoteURL));
}
DishProcessor dishList = new DishProcessor(document);
dishList.GenerateList();
return dishList.Dishes;
}
// POST api/values
public void Post([FromBody]string value)
{
}
// PUT api/values/5
public void Put(int id, [FromBody]string value)
{
}
// DELETE api/values/5
public void Delete(int id)
{
}
}
}