public async Task <IActionResult> CreateMeal([FromBody] MealDTO mealDTO) { var command = new CreateMealCommand(mealDTO.Meal, mealDTO.Price, mealDTO.Url); var result = await _mediatr.Send(command); return(result.Failure ? Conflict(result) : (IActionResult)Created(string.Empty, result.Success)); }
public async Task <IActionResult> Post([FromBody] CreateMealCommand command) { if (!this.ModelState.IsValid) { return(this.BadRequest(this.ModelState)); } var response = await this._mediator.Send(command); return(this.Created(Url.RouteUrl("GetMealById", new { id = response.Id }), new { })); }