Exemplo n.º 1
0
        public FindIngredientsResponse Find(FindIngredientsRequest request)
        {
            try
            {
                _ingredientQuery.WithOnlyActivated(true);
                _ingredientQuery.WithOnlyStatusActivated(request.OnlyStatusActivated);
                _ingredientQuery.WithOnlyStatusDeactivated(request.OnlyStatusDeactivated);
                _ingredientQuery.WithIngredientGroup(request.IngredientGroupId);
                _ingredientQuery.WithName(request.Name);
                _ingredientQuery.WithoutIds(request.WithoutIds);
                _ingredientQuery.WithUnit(request.Unit);
                _ingredientQuery.Sort(request.Sort, request.SortBy);
                var totalRecords = _ingredientQuery.TotalRecords();
                _ingredientQuery.Paginate(request.StartPage, request.EndPage);
                var ingredients = _ingredientQuery.Execute();

                return(new FindIngredientsResponse
                {
                    Ingredients = TypeAdapter.Adapt <List <IngredientResponse> >(ingredients),
                    TotalRecords = totalRecords
                });
            }
            catch (DataAccessException)
            {
                throw new ApplicationException();
            }
        }
Exemplo n.º 2
0
 public FindIngredientsResponse Get(FindIngredientsRequest request)
 {
     return(_ingredientService.Find(request));
 }