public async System.Threading.Tasks.Task <ActionResult> SearchAsync(string CCont, int?pageIndex, int?pageSize) { var result = new ResultModel(); if (string.IsNullOrEmpty(CCont)) { result.Code = 1002; result.Message = "CCont"; return(Jsonp(result, JsonRequestBehavior.AllowGet)); } if (pageIndex == null || pageIndex < 0) { result.Code = 1002; result.Message = " pageIndex "; return(Jsonp(result, JsonRequestBehavior.AllowGet)); } if (pageSize == null || pageSize < 0) { result.Code = 1002; result.Message = " pageSize "; return(Jsonp(result, JsonRequestBehavior.AllowGet)); } try { var lst = await repository.GetAllListAsync((int)pageIndex, (int)pageSize, m => (m.creatorName.Contains(CCont) || m.title.Contains(CCont) || m.contents.Contains(CCont)) && m.status == 0); if (lst != null && lst.Count() > 0) { var data = Mapper.Map <IQueryable <Article>, IList <ArticleListModel> >(lst); result.Code = 0; result.Message = string.Empty; result.Data = data; result.allpageNum = lst.Count(); return(Jsonp(result, JsonRequestBehavior.AllowGet)); } else { result.Code = 0; result.Message = "not found"; return(Jsonp(result, JsonRequestBehavior.AllowGet)); } } catch (Exception ex) { result.Code = 1001; result.Message = ex.Message; return(Jsonp(result, JsonRequestBehavior.AllowGet)); } }
private async Task <IList <long> > GetAllCategoriesByIdAsync(long categoryid) { var service = new EasonRepository <ArticleCategory, long>(); var oldList = await service.GetAllListAsync(); var newList = new List <long>(); if (!newList.Contains(categoryid)) { newList.Add(categoryid); GetChild(categoryid, oldList, newList); } return(newList); }
public async System.Threading.Tasks.Task <ActionResult> ListAsync(long?id, int?pageIndex, int?pageSize) { var result = new ResultModel(); if (id == null || id < 0) { result.Code = 1002; result.Message = " id "; return(Jsonp(result, JsonRequestBehavior.AllowGet)); } if (pageIndex == null || pageIndex < 0) { result.Code = 1002; result.Message = " pageIndex "; return(Jsonp(result, JsonRequestBehavior.AllowGet)); } if (pageSize == null || pageSize < 0) { result.Code = 1002; result.Message = " pageSize "; return(Jsonp(result, JsonRequestBehavior.AllowGet)); } try { var list = (await repository.GetAllListAsync((int)pageIndex, (int)pageSize, m => m.articleId == id && m.status == 0)).ToList(); if (list != null && list.Count > 0) { var data = Mapper.Map <IList <ArticleComment>, IList <CommentListModel> >(list); result.Code = 0; result.Message = string.Empty; result.Data = data; result.allpageNum = await repository.CountAsync(m => m.articleId == id && m.status == 0); return(Jsonp(result, JsonRequestBehavior.AllowGet)); } else { result.Code = 1003; result.Message = "not found"; return(Jsonp(result, JsonRequestBehavior.AllowGet)); } } catch (Exception ex) { result.Code = 1001; result.Message = ex.Message; return(Jsonp(result, JsonRequestBehavior.AllowGet)); } }
public async Task <int> remain() { var res = new EasonRepository <ShortMessage, long>(); int result = 0; int cost = await res.CountAsync(); var list = await repository.GetAllListAsync(); foreach (var item in list) { result += item.count; } result = result - cost; return(result); }
public async System.Threading.Tasks.Task <ActionResult> Index(int?pageIndex, int?pageSize) { EasonRepository <IndexBanner, long> idx = new EasonRepository <IndexBanner, long>();; var result = new ResultModel(); if (pageIndex == null || pageIndex < 0) { result.Code = 1002; result.Message = " pageIndex "; return(Jsonp(result, JsonRequestBehavior.AllowGet)); } if (pageSize == null || pageSize < 0) { result.Code = 1002; result.Message = " pageSize "; return(Jsonp(result, JsonRequestBehavior.AllowGet)); } try { var list = (await idx.GetAllListAsync((int)pageIndex, (int)pageSize, m => m.status == 0)).ToList(); if (list != null && list.Count() > 0) { ; result.Code = 0; result.Message = string.Empty; result.Data = list; result.allpageNum = await idx.CountAsync(m => m.status == 0); return(Jsonp(result, JsonRequestBehavior.AllowGet)); } else { result.Code = 0; result.Message = "not found"; return(Jsonp(result, JsonRequestBehavior.AllowGet)); } } catch (Exception ex) { result.Code = 1001; result.Message = ex.Message; return(Jsonp(result, JsonRequestBehavior.AllowGet)); } }
public async Task <ActionResult> Banner(long?CategoryCode, int?pageIndex, int?pageSize) { var result = new ResultModel(); if (CategoryCode == null || CategoryCode < 0) { result.Code = 1002; result.Message = "CategoryCode "; return(Jsonp(result, JsonRequestBehavior.AllowGet)); } if (pageIndex == null || pageIndex < 0) { result.Code = 1002; result.Message = " pageIndex "; return(Jsonp(result, JsonRequestBehavior.AllowGet)); } if (pageSize == null || pageSize < 0) { result.Code = 1002; result.Message = " pageSize "; return(Jsonp(result, JsonRequestBehavior.AllowGet)); } try { var lst = await repository.GetAllListAsync((int)pageIndex, (int)pageSize, m => m.categoryId == CategoryCode && m.status == 0); var data = Mapper.Map <IQueryable <Article>, IList <BannerModel> >(lst); result.Code = 0; result.Message = string.Empty; result.Data = data; result.allpageNum = lst.Count(); return(Jsonp(result, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { result.Code = 1001; result.Message = ex.Message; return(Jsonp(result, JsonRequestBehavior.AllowGet)); } }
public async System.Threading.Tasks.Task <ActionResult> ItemsAsync(long?CategoryCode) { var result = new ResultModel(); if (CategoryCode == null || CategoryCode < 0) { result.Code = 1002; result.Message = "CategoryCode "; return(Jsonp(result, JsonRequestBehavior.AllowGet)); } try { var lst = await repository.GetAllListAsync(m => m.parentId == CategoryCode && m.status == 0); if (lst != null && lst.Count() > 0) { var data = lst; result.Code = 0; result.Message = string.Empty; result.Data = data; result.allpageNum = lst.Count(); return(Jsonp(result, JsonRequestBehavior.AllowGet)); } else { result.Code = 1003; result.Message = "not found"; return(Jsonp(result, JsonRequestBehavior.AllowGet)); } } catch (Exception ex) { result.Code = 1001; result.Message = ex.Message; return(Jsonp(result, JsonRequestBehavior.AllowGet)); } }