public ActionResult AddMealCategory(MealCategoryDTO mc)
        {
            MealCategory mealcat = new MealCategory()
            {
                Id       = Guid.NewGuid(),
                Category = mc.Category,
            };

            if (_mealCategoryRepository.AddMealCategory(mealcat))
            {
                return(Ok("New Meal Category is added!"));
            }
            return(BadRequest("Oops, something went wrong!"));
        }
示例#2
0
        public IActionResult Post(MealCategoryDTO category)
        {
            if (category == null)
            {
                return(BadRequest());
            }

            var finalCategory = new MealCategory()
            {
                Name = category.Name
            };

            categoryService.Add(finalCategory);
            return(CreatedAtRoute("GetCategory", new { id = finalCategory.Id }, finalCategory)); // Set Custom Name Parameter for HttpGet!
        }
示例#3
0
        public IActionResult Put(int id, [FromBody] MealCategoryDTO category)
        {
            if (category == null)
            {
                return(BadRequest());
            }

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var result = categoryService.GetCategory(id);

            if (result == null)
            {
                return(NotFound());
            }

            result.Name = category.Name;
            categoryService.Update(result);

            return(NoContent());
        }
示例#4
0
 public IHttpActionResult Put([FromUri] int id, [FromBody] MealCategoryDTO MealCategory)
 {
     MealCategoryService.PrePutDTO(ModelState, currentClient, id, MealCategory);
     return(Ok());
 }
示例#5
0
 public MealCategoryDTO Post([FromBody] MealCategoryDTO MealCategory)
 {
     return(MealCategoryService.PrePostDTO(ModelState, currentClient, MealCategory));
 }