惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

月光博客
月光博客
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
阮一峰的网络日志
阮一峰的网络日志
罗磊的独立博客
T
Tailwind CSS Blog
博客园_首页
博客园 - 司徒正美
Google DeepMind News
Google DeepMind News
Hugging Face - Blog
Hugging Face - Blog
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
V
V2EX
J
Java Code Geeks
量子位
D
DataBreaches.Net
MongoDB | Blog
MongoDB | Blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Microsoft Azure Blog
Microsoft Azure Blog
P
Proofpoint News Feed
C
Check Point Blog
V
Visual Studio Blog
H
Help Net Security
Recent Announcements
Recent Announcements
Engineering at Meta
Engineering at Meta

博客园 - 如是如是

将博客搬至CSDN 钱钟书夫人杨绛:《一百岁感言》 DOM无关事件 用到了反射,还不错。可以取到动态创建类的值 JounceTabRegion Jounce Blendable RestShart Post 方式传递poco给Web api Using ASP.NET Web API with ASP.NET Web Forms How to Migrate from WCF Web API to ASP.NET Web API ASP.NET Web API MVC-REST-SilverLight 之 架构 MVC-REST-SilverLight 之 RestExample.Model.Silverlight\Customer.cs - 如是如是 MVC-REST-SilverLight 之MainPage.xaml.cs MVC-REST-SilverLight 之 ViewModels\MainViewModel.cs - 如是如是 MVC-REST-SilverLight 之 Global.asax.cs MVC-REST-SilverLight 之 HttpConfiguration MVC-REST-SilverLight 之 MapServiceRoute MEF Export 和 Import 委托 设计模式-访问者
MVC-REST-SilverLight 之Api\CustomerApi.cs - 如是如是 - 博...
如是如是 · 2012-02-21 · via 博客园 - 如是如是

using System.Collections.Generic;

using System.ServiceModel;

using System.ServiceModel.Web;

using RestExample.Model;

using RestExample.Web.Resources;

namespace RestExample.Web.Api

{

[ServiceContract]

public class CustomerApi

{

[WebGet(UriTemplate = "")]

public List<Customer> GetAll()

{

var rep = new CustomerRepository();

return rep.GetAllCustomers();

}

[WebGet(UriTemplate = "{id}")]

public Customer GetByID(int id)

{

var rep = new CustomerRepository();

return rep.GetSingleCustomerByID(id);

}

[WebInvoke(UriTemplate = "", Method = "POST")]

public Customer Post(Customer customer)

{

var rep = new CustomerRepository();

Customer cust = rep.AddOrUpdate(customer);

return cust;

}

[WebInvoke(UriTemplate = "{id}", Method = "DELETE")]

public Customer Delete(int id)

{

var rep = new CustomerRepository();

var cust = rep.GetSingleCustomerByID(id);

rep.Delete(id);

return cust;

}

}

}