public async Task <PagedList <IngredientDto> > GetIngredientsWithPaginations(PaginationParams param, int glueid) { var glueIngredient = _repoGlueIngredient.GetAll(); var lists = _repoIngredient.FindAll().Where(x => x.isShow == true).ProjectTo <IngredientDto>(_configMapper).OrderByDescending(x => x.ID).Select(x => new IngredientDto { ID = x.ID, Name = x.Name, Code = x.Code, CreatedDate = x.CreatedDate, Percentage = glueIngredient.FirstOrDefault(a => a.GlueID == glueid && a.IngredientID == x.ID).Percentage, Status = glueIngredient.Any(a => a.GlueID == glueid && a.IngredientID == x.ID) }); return(await PagedList <IngredientDto> .CreateAsync(lists, param.PageNumber, param.PageSize)); }
public async Task <bool> CheckExistsName(string name) { return(await _repoIngredient.FindAll().AnyAsync(x => x.Name.Trim().ToLower().Equals(name.Trim().ToLower()))); }
public IEnumerable <Ingredient> FindAll() { return(_ingredientRepository.FindAll()); }
//Lấy danh sách Ingredient và phân trang public async Task <PagedList <IngredientDto> > GetWithPaginations(PaginationParams param) { var lists = _repoIngredient.FindAll().Include(x => x.Supplier).ProjectTo <IngredientDto>(_configMapper).OrderByDescending(x => x.ID); return(await PagedList <IngredientDto> .CreateAsync(lists, param.PageNumber, param.PageSize)); }