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!")); }
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! }
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()); }
public IHttpActionResult Put([FromUri] int id, [FromBody] MealCategoryDTO MealCategory) { MealCategoryService.PrePutDTO(ModelState, currentClient, id, MealCategory); return(Ok()); }
public MealCategoryDTO Post([FromBody] MealCategoryDTO MealCategory) { return(MealCategoryService.PrePostDTO(ModelState, currentClient, MealCategory)); }