public async Task <bool> CheckCode(string Name, long Id) { int i = 0; //添加 if (Id == 0) { i = await RoleRep.GetCountAsync(o => o.Name == Name); if (i > 0) { return(true); } else { return(false); } } //编辑 i = await RoleRep.GetCountAsync(o => o.Name == Name && o.Id != Id); if (i > 0) { return(true); } else { return(false); } }
public async Task <PageResult <Role> > GetPageAsync(int pageNumber, int rowsPrePage, RoleOption filter) { List <Role> data = new List <Role>(); PageResult <Role> list = new PageResult <Role>(); string orderby = " id desc"; var predicate = PredicateBuilder.True <Role>(); if (!string.IsNullOrWhiteSpace(filter.Name)) { predicate = predicate.And(o => o.Name.Contains(filter.Name)); } var tlist = await RoleRep.Find(pageNumber, rowsPrePage, orderby, predicate).ToListAsync(); list.Data = tlist.ToList(); int total = await RoleRep.GetCountAsync(predicate); list.ItemCount = total; return(list); }