Beispiel #1
0
        public async Task <BaseDtoListResponse <FoodItemDto> > ListAsync()
        {
            try
            {
                IList <FoodItem> items = await _foodItemRepository.ListAll();

                if (items != null)
                {
                    IList <FoodItemDto> result = _mapper.Map <IList <FoodItem>, IList <FoodItemDto> >(items);
                    BaseDtoListResponse <FoodItemDto> response = new BaseDtoListResponse <FoodItemDto>(result);
                    return(response);
                }
                else
                {
                    return(new BaseDtoListResponse <FoodItemDto>("No Items found, please try after adding new food item(s)"));
                }
            }
            catch (Exception ex)
            {
                return(new BaseDtoListResponse <FoodItemDto>(ex.Message));
            }
        }