示例#1
0
        public object Get(Product request)
        {
            if (request.Id != default(long))
                return Db.GetById<Product>(request.Id);

            return Db.Select<Product>();
        }
示例#2
0
        public object Post(Product product)
        {
            Db.Save(product);
            product.Id = (int)Db.GetLastInsertId();

            var pathToNewResource = base.RequestContext.AbsoluteUri.CombineWith(product.Id.ToString());
            return HttpResult.Status201Created(product, pathToNewResource);
        }
示例#3
0
 public Product Put(Product product)
 {
     Db.Save(product);
     return product;
 }
示例#4
0
 public void Delete(Product request)
 {
     Db.DeleteById<Product>(request.Id);
 }