コード例 #1
0
        public long SaveWorkplan(Workplan workplan)
        {
            using (var uow = ModelFactory.Create())
            {
                var recipeRepo = uow.GetRepository <IProductRecipeEntityRepository>();
                // Update all non-clone recipes of that workplan
                var affectedRecipes = recipeRepo.Linq
                                      .Where(r => r.WorkplanId == workplan.Id && r.Classification > 0).ToList();

                var entity = RecipeStorage.SaveWorkplan(uow, workplan);
                foreach (var recipe in affectedRecipes)
                {
                    recipe.Workplan = entity;
                }

                uow.SaveChanges();

                foreach (var recipeEntity in affectedRecipes)
                {
                    var recipe = Storage.LoadRecipe(recipeEntity.Id);
                    RaiseRecipeChanged(recipe);
                }

                return(entity.Id);
            }
        }
コード例 #2
0
 public Workplan LoadWorkplan(long workplanId)
 {
     using (var uow = ModelFactory.Create())
     {
         return(RecipeStorage.LoadWorkplan(uow, workplanId));
     }
 }
コード例 #3
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);
        }
コード例 #4
0
        /// <summary>
        /// Load recipe object from entity.
        /// </summary>
        private IProductRecipe LoadRecipe(IUnitOfWork uow, ProductRecipeEntity recipeEntity)
        {
            var productRecipe = RecipeConstructors[recipeEntity.Type]();

            RecipeStorage.CopyToRecipe(recipeEntity, productRecipe);
            productRecipe.Product = LoadType(uow, productRecipe.Product.Id);

            RecipeStrategies[recipeEntity.Type].LoadRecipe(recipeEntity, productRecipe);

            return(productRecipe);
        }
コード例 #5
0
        public long SaveWorkplan(Workplan workplan)
        {
            using (var uow = ModelFactory.Create())
            {
                var entity = RecipeStorage.SaveWorkplan(uow, workplan);

                uow.SaveChanges();

                return(entity.Id);
            }
        }