public FoodCategoryDto ToDto(FoodCategory foodCategory)
        {
            FoodCategoryDto foodCategoryDto = new FoodCategoryDto();

            //foodCategoryDto.drink = foodCategory.drink;
            //foodCategoryDto.food = foodCategory.food;
            return(foodCategoryDto);
        }
Beispiel #2
0
        public async Task <BaseDtoResponse <FoodCategoryDto> > GetById(Guid id)
        {
            FoodCategory category = await _foodCategoryRepository.GetById(id);

            if (category == null)
            {
                return(new BaseDtoResponse <FoodCategoryDto>("Category Not Found"));
            }
            FoodCategoryDto result = _mapper.Map <FoodCategory, FoodCategoryDto>(category);

            return(new BaseDtoResponse <FoodCategoryDto>(result));
        }
Beispiel #3
0
        public async Task <BaseDtoResponse <FoodCategoryDto> > Add(FoodCategoryCreateRequest request)
        {
            try
            {
                FoodCategory model    = _mapper.Map <FoodCategoryCreateRequest, FoodCategory>(request);
                FoodCategory category = await _foodCategoryRepository.Add(model);

                if (category != null)
                {
                    FoodCategoryDto result = _mapper.Map <FoodCategory, FoodCategoryDto>(category);
                    return(new BaseDtoResponse <FoodCategoryDto>(result));
                }
                else
                {
                    return(new BaseDtoResponse <FoodCategoryDto>("Unable to create a new category, try again"));
                }
            }
            catch (Exception ex)
            {
                return(new BaseDtoResponse <FoodCategoryDto>($"An error occurred when saving the category: {ex.Message}"));
            }
        }
Beispiel #4
0
        public async Task <BaseDtoResponse <FoodCategoryDto> > Delete(Guid id)
        {
            try
            {
                FoodCategory category = await _foodCategoryRepository.GetById(id);

                if (category != null)
                {
                    await _foodCategoryRepository.Delete(category);

                    FoodCategoryDto result = _mapper.Map <FoodCategory, FoodCategoryDto>(category);
                    return(new BaseDtoResponse <FoodCategoryDto>(result));
                }
                else
                {
                    return(new BaseDtoResponse <FoodCategoryDto>("Unable to delete: Category Not found"));
                }
            }
            catch (Exception ex)
            {
                return(new BaseDtoResponse <FoodCategoryDto>($"An error occurred when deleting the category: {ex.Message}"));
            }
        }
        public FoodCategory ToEntity(FoodCategoryDto foodCategoryDto)
        {
            FoodCategory foodCategory = new FoodCategory();

            return(foodCategory);
        }