Beispiel #1
0
        /// <summary>
        /// Saves <see cref="ProductRecipe"/> to database and return the <see cref="ProductRecipeEntity"/>
        /// </summary>
        protected ProductRecipeEntity SaveRecipe(IUnitOfWork uow, IProductRecipe recipe)
        {
            var entity = RecipeStorage.SaveRecipe(uow, recipe);

            RecipeStrategies[recipe.GetType().Name].SaveRecipe(recipe, entity);

            return(entity);
        }
        /// <summary>
        /// Save recipe to given <see cref="IUnitOfWork"/>
        /// </summary>
        public static ProductRecipeEntity SaveRecipe(IUnitOfWork uow, IProductRecipe recipe)
        {
            var entity = uow.GetEntity <ProductRecipeEntity>(recipe);

            entity.Type           = recipe.GetType().Name;
            entity.Revision       = recipe.Revision;
            entity.Name           = recipe.Name;
            entity.State          = (int)recipe.State;
            entity.Classification = (int)recipe.Classification;
            entity.ProductId      = recipe.Product.Id;

            var workplanRecipe = recipe as IWorkplanRecipe;

            if (workplanRecipe != null)
            {
                entity.WorkplanId = workplanRecipe.Workplan.Id;
            }

            return(entity);
        }