migrate to new git
This commit is contained in:
111
web/App_Code/api/activity_kindController.cs
Normal file
111
web/App_Code/api/activity_kindController.cs
Normal file
@@ -0,0 +1,111 @@
|
||||
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;
|
||||
using static TreeView;
|
||||
|
||||
[ezAuthorize]
|
||||
public class activity_kindController : ApiController
|
||||
{
|
||||
private Model.ezEntities _db = new Model.ezEntities();
|
||||
// GET api/<controller>
|
||||
public IEnumerable<Model.actItem_kind> Get()
|
||||
{
|
||||
var list = _db.actItem_kind.OrderBy(q=>q.kind).ToList();
|
||||
if (list == null) throw new HttpResponseException(HttpStatusCode.NotFound);
|
||||
return list;
|
||||
}
|
||||
|
||||
// GET api/<controller>/5
|
||||
public Model.actItem_kind Get(int id)
|
||||
{
|
||||
var item = _db.actItem_kind.Where(q => q.num == id).FirstOrDefault();
|
||||
return item;
|
||||
}
|
||||
|
||||
// POST api/<controller>
|
||||
public void Post([FromBody] string value)
|
||||
{
|
||||
}
|
||||
|
||||
// PUT api/<controller>/5
|
||||
public void Put(int id, [FromBody] string value)
|
||||
{
|
||||
}
|
||||
|
||||
// DELETE api/<controller>/5
|
||||
public void Delete(int id)
|
||||
{
|
||||
}
|
||||
[HttpGet]
|
||||
[Route("api/actItem_kind/count")]
|
||||
public int Count()
|
||||
{
|
||||
var count = _db.actItem_kind.Count();
|
||||
return count;
|
||||
}
|
||||
[HttpPost]
|
||||
[Route("api/actItem_kind/GetList")]
|
||||
public IHttpActionResult GetList([FromBody] Model.ViewModel.actItem_kind q,
|
||||
int page, int pageSize = 10, string sortBy = "", bool sortDesc = false)
|
||||
{
|
||||
var qry = _db.actItem_kind.AsEnumerable();
|
||||
if (!string.IsNullOrEmpty(q.kind))
|
||||
qry = qry.Where(o => o.kind.Contains(q.kind));
|
||||
if (!string.IsNullOrEmpty(q.status))
|
||||
qry = qry.Where(o => o.status.Contains(q.status));
|
||||
//qry = qry.OrderBy(o => o.kind);
|
||||
|
||||
var qry2 = new TreeView().get_data2(qry.Select(o => new TreeItem()
|
||||
{
|
||||
kind = o.kind,
|
||||
num = o.num,
|
||||
root = o.root,
|
||||
range = o.range,
|
||||
}).OrderBy(x => x.root).ThenBy(x => x.kind).ToList(), 0, 0);
|
||||
|
||||
|
||||
var ret = new
|
||||
{
|
||||
list = qry2.ToPagedList(page, pageSize).Select(x => new
|
||||
{
|
||||
num = x.num,
|
||||
kind = new TreeView().RptDash(x.Level) + x.kind,
|
||||
//status = x.status,
|
||||
|
||||
}),
|
||||
count = qry.Count()
|
||||
|
||||
};
|
||||
return Ok(ret);
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
[Route("api/actItem_kind/GetAll")]
|
||||
public IHttpActionResult GetAll()
|
||||
{
|
||||
//var list = _db.actItem_kind.OrderBy(q => q.kind).ToList();
|
||||
var list = new TreeView().get_data2(_db.actItem_kind.Select(o => new TreeItem()
|
||||
{
|
||||
kind = o.kind,
|
||||
num = o.num,
|
||||
root = o.root,
|
||||
range = o.range,
|
||||
}).OrderBy(x => x.root).ThenBy(x => x.kind).ToList(), 0, 0)
|
||||
.Select(x => new
|
||||
{
|
||||
num = x.num,
|
||||
kind = new TreeView().RptDash(x.Level) + x.kind,
|
||||
|
||||
});
|
||||
|
||||
if (list == null) throw new HttpResponseException(HttpStatusCode.NotFound);
|
||||
return Ok(list);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user