migrate to new git
This commit is contained in:
67
web/App_Code/api/appellationController.cs
Normal file
67
web/App_Code/api/appellationController.cs
Normal file
@@ -0,0 +1,67 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Web.Http;
|
||||
using PagedList;
|
||||
using Newtonsoft.Json;
|
||||
using System.Collections;
|
||||
|
||||
|
||||
[ezAuthorize]
|
||||
public class appellationController : BaseApiController
|
||||
{
|
||||
// GET api/<controller>
|
||||
public IEnumerable<Model.appellation> Get()
|
||||
{
|
||||
var list = _db.appellations.ToList();
|
||||
if (list == null) throw new HttpResponseException(HttpStatusCode.NotFound);
|
||||
return list;
|
||||
}
|
||||
|
||||
// GET api/<controller>/5
|
||||
public Model.appellation Get(int id)
|
||||
{
|
||||
var item = _db.appellations.Where(q => q.num == id).FirstOrDefault();
|
||||
if (item == null) throw new HttpResponseException(HttpStatusCode.NotFound);
|
||||
return item;
|
||||
}
|
||||
|
||||
// POST api/<controller>
|
||||
public void Post([FromBody] string value)
|
||||
{
|
||||
}
|
||||
|
||||
// PUT api/<controller>/5
|
||||
public void Put(string id, [FromBody] string value)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
[HttpPost]
|
||||
[Route("api/appellation/GetList")]
|
||||
public IHttpActionResult GetList([FromBody] Model.appellation q,
|
||||
int page, int pageSize = 10, string sortBy = "", bool sortDesc = false)
|
||||
{
|
||||
var qry = _db.appellations.AsEnumerable();
|
||||
|
||||
|
||||
qry = qry.OrderBy(o => o.num);
|
||||
|
||||
var ret = new
|
||||
{
|
||||
list = qry.ToPagedList(page, pageSize).Select(x => new
|
||||
{
|
||||
num = x.num,
|
||||
title = x.title,
|
||||
}),
|
||||
count = qry.Count()
|
||||
};
|
||||
|
||||
|
||||
if (ret.list == null) throw new HttpResponseException(HttpStatusCode.NotFound);
|
||||
return Ok(ret);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user