private DishCommand CreateDishCommand(DishCreateRequest dishRequest) { var dishCommand = new DishCommand { Id = m_idGenerator.GenerateId(), Name = dishRequest.Name, Description = dishRequest.Description, Recipe = dishRequest.Recipe, Difficulty = dishRequest.Difficulty, Duration = dishRequest.Duration, Author = dishRequest.Author, TimeAdded = DateTime.Today }; return(dishCommand); }
public async Task <Dish> PostDish(DishCreateRequest dish) { var dishCommand = CreateDishCommand(dish); var dishTagCreateRequest = CreteDishCreateRequest(dishCommand, dish); await m_commandExecutor.ExecuteAsync(dishCommand); if (dishTagCreateRequest.TagIds != null) { await m_dishTagService.AddTagsToDish(dishTagCreateRequest); } if (dish.DishIngredients != null) { await m_dishIngredientService.AddIngredientsToDish(dishCommand.Id, dish.DishIngredients); } var postedDish = await FindDish(dishCommand.Id); return(postedDish); }
private static DishTagCreateRequest CreteDishCreateRequest(DishCommand dishCommand, DishCreateRequest dishCreateRequest) { return(new DishTagCreateRequest { DishId = dishCommand.Id, TagIds = dishCreateRequest.TagIds }); }