public async Task <JsonpResult> Delete(string strid) { if (string.IsNullOrEmpty(strid)) { return(Jsonp(new { success = true }, JsonRequestBehavior.AllowGet)); } long[] ids = Array.ConvertAll(strid.Split(','), s => long.Parse(s)); if (ids != null && ids.Length > 0) { var lst = repository.GetAll().WhereIn(m => m.id, ids); foreach (var item in lst) { repository.Delete(item); } await repository.UnitOfWork.CommitAsync(); } return(Jsonp(new { success = true }, JsonRequestBehavior.AllowGet)); }
// GET: New public async System.Threading.Tasks.Task <ActionResult> IndexAsync(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 allC = await GetAllCategoriesByIdAsync((long)CategoryCode); var lst = repository.GetAllList((int)pageIndex, (int)pageSize, m => m.status == 0, m => m.categoryId, allC.ToArray()); EasonRepository <ArticleCategory, long> category = new EasonRepository <ArticleCategory, long>(); 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 = repository.GetAllList(m => m.status == 0, m => m.categoryId, allC.ToArray()).Count(); result.ChildName = category.GetAll(m => m.parentId == CategoryCode); 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)); } }