zoukankan      html  css  js  c++  java
  • MVCRESTSilverLight 之Api\CustomerApi.cs

    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;

    }

    }

    }

     

     
     
    作者:易简.道    
     
    本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。
  • 相关阅读:
    three.js详解
    Javascript的原型
    Transform? Transition? Animation?
    Backbone源码分析Backbone架构+流程图
    对象是引用的注意原型中的属性改变
    MySQL+ JSP+Tomcat開發指引
    MySQL應用分析
    SQL 日期
    MySQL安裝
    MSE错误应对分享
  • 原文地址:https://www.cnblogs.com/xyicheng/p/2361921.html
Copyright © 2011-2022 走看看