public async Task <RecipeCategory> AddRecipeCategory(AddRecipeCategoryDto newRecipeCategory)
        {
            RecipeCategory category = _mapper.Map <RecipeCategory>(newRecipeCategory);

            await _context.RecipeCategories.AddAsync(category);

            await _context.SaveChangesAsync();

            return(category);
        }
        public void AddRecipeCategory_MinimalRecipeCategory_NoErrors()
        {
            AddRecipeCategoryDto addRecipeCategoryDto = new AddRecipeCategoryDto()
            {
                Name = "category name"
            };

            Assert.DoesNotThrowAsync(async() =>
            {
                await _recipeCategoryRepository.AddRecipeCategory(addRecipeCategoryDto);
            });
        }
Beispiel #3
0
        public async Task <ActionResult> Post([FromBody] AddRecipeCategoryDto input)
        {
            //TODO: add standard on naming
            var recipeCategory = this._mapper.Map <AddRecipeCategoryDto, RecipeCategory>(input);
            var response       = await this._recipeCategoryService.AddOne(recipeCategory);

            // this._context.recipeCategorys.Add(recipeCategory);
            // FIXME: Bug on saving new recipeCategory..
            // var result = this._context.SaveChanges();
            if (!response.Success)
            {
                return(UnprocessableEntity(response));
            }
            //return Ok($"Object added. ID:{createdEntityId}");
            return(Ok(response));
        }
Beispiel #4
0
 public async Task <IActionResult> AddGroceryCategory(AddRecipeCategoryDto newRecipeCategory)
 {
     return(Ok(await _recipeCategoryRepository.AddRecipeCategory(newRecipeCategory)));
 }