Example #1
0
        public List <Domain.Model.Size> GetDomainSizeList(ICollection <Size> sizes, ICollection <Domain.Model.Consumable> consumables)
        {
            List <Domain.Model.Size> result = new List <Domain.Model.Size>();

            foreach (var size in sizes)
            {
                var position   = Domain.Model.Position.Create(size.Position);
                var domainSize = new Domain.Model.Size(size.Id, position);
                domainSize.UpdateSize(size);
                domainSize.UpdateIngredients(size.Ingredients, consumables);
                result.Add(domainSize);
            }
            return(result);
        }
Example #2
0
        public List <Domain.Model.Ingredient> GetDomainIngredientList(ICollection <Ingredient> ingredients, ICollection <Domain.Model.Consumable> consumables)
        {
            List <Domain.Model.Ingredient> result = new List <Domain.Model.Ingredient>();

            foreach (var ingredient in ingredients)
            {
                var position         = Domain.Model.Position.Create(ingredient.Position);
                var size             = new Domain.Model.Size(ingredient.Size.Id, position);
                var consumable       = consumables.First(p => p.Id == ingredient.Consumable.Id);
                var domainIngredient = new Domain.Model.Ingredient(ingredient.Id, size, consumable);
                size.UpdateSize(ingredient.Size);
                var success = consumable.TryUpdateConsumable(ingredient.Consumable, out _);
                if (success)
                {
                    success = domainIngredient.TryUpdateIngredient(ingredient, out _);
                }
                if (success)
                {
                    result.Add(domainIngredient);
                }
            }
            return(result);
        }