示例#1
0
        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);
        }
示例#2
0
        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);
        }
示例#3
0
 private static DishTagCreateRequest CreteDishCreateRequest(DishCommand dishCommand, DishCreateRequest dishCreateRequest)
 {
     return(new DishTagCreateRequest {
         DishId = dishCommand.Id, TagIds = dishCreateRequest.TagIds
     });
 }