public string Get(int pageSize, int pageNo) { Console.WriteLine("HttpGet[\"{ pageSize}/{ pageNo}\")]"); StateOfRequest mState = new StateOfRequest(""); mState.PageSize = pageSize; mState.CurrentPageNo = pageNo; List <Singer> singers = _singersManager.GetOnePageOfSingers(mState); JObject jObjectForAll = new JObject(); jObjectForAll.Add("pageNo", mState.CurrentPageNo); jObjectForAll.Add("pageSize", mState.PageSize); jObjectForAll.Add("totalRecords", mState.TotalRecords); jObjectForAll.Add("totalPages", mState.TotalPages); JObject jObject; JArray jArray = new JArray(); foreach (var singer in singers) { jObject = JsonUtil.ConvertSingerToJsongObject(singer); jArray.Add(jObject); } jObjectForAll.Add("singers", jArray); return(jObjectForAll.ToString()); }
public string Get() { Console.WriteLine("Get all singers."); StateOfRequest mState = new StateOfRequest("SingNo"); List <Singer> singers = _singersManager.GetAllSingers(mState); JObject jObjectForAll = new JObject(); jObjectForAll.Add("pageNo", mState.CurrentPageNo); jObjectForAll.Add("pageSize", mState.PageSize); jObjectForAll.Add("totalRecords", mState.TotalRecords); jObjectForAll.Add("totalPages", mState.TotalPages); JObject jObject; JArray jArray = new JArray(); foreach (var singer in singers) { jObject = JsonUtil.ConvertSingerToJsongObject(singer); jArray.Add(jObject); } jObjectForAll.Add("singers", jArray); return(jObjectForAll.ToString()); }
public async Task <string> Get(int id) { // get one singer Singer singer = await _singersManager.FindOneSingerById(id); JObject jObject = JsonUtil.ConvertSingerToJsongObject(singer); JObject returnJSON = new JObject(); returnJSON.Add("singer", jObject); return(returnJSON.ToString()); }
private JObject GetSingersBySingerTypeId(int id, String sex, int pageSize, int pageNo, string orderBy, string filter) { // orderBy is either "", or "SingNo", or "SingNa" string orderByParam; if (string.IsNullOrEmpty(orderBy)) { orderByParam = ""; } else { orderByParam = orderBy.Trim(); } string filterParam; if (string.IsNullOrEmpty(filter)) { filterParam = ""; } else { filterParam = filter.Trim(); } StateOfRequest mState = new StateOfRequest(orderByParam); mState.PageSize = pageSize; mState.CurrentPageNo = pageNo; mState.QueryCondition = filterParam; List <Singer> singers = _singersManager.GetOnePageOfSingersByAreaSex(mState, id, sex, true); JObject jObjectForAll = new JObject(); jObjectForAll.Add("pageNo", mState.CurrentPageNo); jObjectForAll.Add("pageSize", mState.PageSize); jObjectForAll.Add("totalRecords", mState.TotalRecords); jObjectForAll.Add("totalPages", mState.TotalPages); JObject jObject; JArray jArray = new JArray(); foreach (var singer in singers) { jObject = JsonUtil.ConvertSingerToJsongObject(singer); jArray.Add(jObject); } jObjectForAll.Add("singers", jArray); return(jObjectForAll); }
public string Get(int pageSize, int pageNo, string orderBy) { Console.WriteLine("HttpGet[\"{ pageSize}/{ pageNo}/{orderBy}\")]"); // orderBy is either "SingNo" or "SingNa" string orderByParam = orderBy.Trim(); if (string.IsNullOrEmpty(orderBy)) { orderByParam = ""; } else { orderByParam = orderBy.Trim(); } StateOfRequest mState = new StateOfRequest(orderByParam); mState.PageSize = pageSize; mState.CurrentPageNo = pageNo; List <Singer> singers = _singersManager.GetOnePageOfSingers(mState); JObject jObjectForAll = new JObject(); jObjectForAll.Add("pageNo", mState.CurrentPageNo); jObjectForAll.Add("pageSize", mState.PageSize); jObjectForAll.Add("totalRecords", mState.TotalRecords); jObjectForAll.Add("totalPages", mState.TotalPages); JObject jObject; JArray jArray = new JArray(); foreach (var singer in singers) { jObject = JsonUtil.ConvertSingerToJsongObject(singer); jArray.Add(jObject); } jObjectForAll.Add("singers", jArray); return(jObjectForAll.ToString()); }