public decimal GetIngredientCategoryBID(decimal?MID)
        {
            IngredientCategory IngC = new IngredientCategory();

            IngC.ICID = db.INGREDIENT_CATEGORY.First(A => A.MANUFACTURER_ID == MID).ID;
            return(IngC.ICID);
        }
Beispiel #2
0
        public ActionResult DeleteConfirmed(int id)
        {
            IngredientCategory ingredientCategory = _ingredientCategoryService.GetById(id);

            _ingredientCategoryService.Delete(ingredientCategory);
            return(RedirectToAction("Index"));
        }
        public async Task <IActionResult> Edit(int id, [Bind("IngredientId,CategoryId")] IngredientCategory ingredientCategory)
        {
            if (id != ingredientCategory.CategoryId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(ingredientCategory);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!IngredientCategoryExists(ingredientCategory.CategoryId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CategoryId"]   = new SelectList(_context.Categories, "CategoryId", "CategoryId", ingredientCategory.CategoryId);
            ViewData["IngredientId"] = new SelectList(_context.Ingredients, "IngredientId", "IngredientId", ingredientCategory.IngredientId);
            return(View(ingredientCategory));
        }
Beispiel #4
0
        public async Task <IEnumerable <Ingredient> > GetIngredientsForCategory(IngredientCategory ingredientType)
        {
            IEnumerable <Ingredient> result = await _context.Ingredients
                                              .Where(x => x.Type == (int)ingredientType)
                                              .ToListAsync();

            return(result);
        }
Beispiel #5
0
        private static void ReadIngredientCategory(string filename, FlavorNetworkContext context)
        {
            var ingredientCategoryCsvSchema = new CsvSchema();

            ingredientCategoryCsvSchema.Properties.Add(new SchemaProperty("Id"));
            ingredientCategoryCsvSchema.Properties.Add(new SchemaProperty("Name"));
            ingredientCategoryCsvSchema.Properties.Add(new SchemaProperty("Category"));

            var ingredientCategoryCsvReader = new CsvReader <IngredientAndCategory>();

            ingredientCategoryCsvReader.CsvDelimiter             = "\t";
            ingredientCategoryCsvReader.UseSingleLineHeaderInCsv = true;
            ingredientCategoryCsvReader.Schema = ingredientCategoryCsvSchema;

            var list = ingredientCategoryCsvReader.Read(File.OpenRead(filename));

            int id = 1;

            foreach (var item in list.Distinct(new CategoryEqualityComparer()))
            {
                var category = new IngredientCategory();
                category.Id          = id;
                category.Name        = item.Category;
                category.Ingredients = new List <Ingredient>();

                context.IngredientCategories.Add(category);

                id++;
            }

            foreach (var item in list)
            {
                item.Id = item.Id + 1;

                var ingredient = new Ingredient();
                ingredient.Id   = item.Id;
                ingredient.Name = GetIngredientName(item.Name);
                ingredient.IngredientCompounds     = new List <IngredientCompound>();
                ingredient.IngredientContributions = new List <IngredientContribution>();
                ingredient.RecipeIngredients       = new List <RecipeIngredient>();

                var category = context.IngredientCategories.Local.SingleOrDefault(r => r.Name.Equals(item.Category));

                if (category != null)
                {
                    ingredient.IngredientCategory   = category;
                    ingredient.IngredientCategoryId = category.Id;
                    category.Ingredients.Add(ingredient);
                    context.Ingredients.Add(ingredient);
                }
                else
                {
                    Console.WriteLine($"Category '{item.Category}' not found!!!");
                }

                //Console.WriteLine($"Id: '{item.Id}', N: '{item.Name}', C: '{item.Category}'");
            }
        }
Beispiel #6
0
 public ActionResult Edit([Bind(Include = "IngredientCategoryId,Name,Id")] IngredientCategory ingredientCategory)
 {
     if (ModelState.IsValid)
     {
         _ingredientCategoryService.Update(ingredientCategory);
         return(RedirectToAction("Index"));
     }
     return(View(ingredientCategory));
 }
Beispiel #7
0
 public Ingredient(string ingredientName, decimal ingredientPrice, bool isAddOn, bool isDairyFree, bool isGlutenFree, bool isVegan, int stockLevel, IngredientCategory ingredientType)
 {
     IngredientName  = ingredientName;
     IngredientPrice = ingredientPrice;
     IsAddOn         = isAddOn;
     IsDairyFree     = isDairyFree;
     IsGlutenFree    = isGlutenFree;
     IsVegan         = isVegan;
     StockLevel      = stockLevel;
     IngredientType  = ingredientType;
 }
        public void AddIngredientCategory(IngredientCategory IC)
        {
            INGREDIENT_CATEGORY ict = new INGREDIENT_CATEGORY();

            ict.ID              = IC.ICID;
            ict.NAME            = IC.Name;
            ict.FRONTEND_ID     = IC.FrontendID;
            ict.MANUFACTURER_ID = IC.ManufacturerID;
            db.INGREDIENT_CATEGORY.Add(ict);
            db.SaveChanges();
        }
 internal static IngredientCategoryModel Create(IngredientCategory obj)
 {
     if (obj == null)
     {
         return(null);
     }
     return(new IngredientCategoryModel()
     {
         Id = obj.Id,
         Name = obj.Name
     });
 }
        public async Task <IActionResult> Create([Bind("IngredientId,CategoryId")] IngredientCategory ingredientCategory)
        {
            if (ModelState.IsValid)
            {
                _context.Add(ingredientCategory);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CategoryId"]   = new SelectList(_context.Categories, "CategoryId", "CategoryId", ingredientCategory.CategoryId);
            ViewData["IngredientId"] = new SelectList(_context.Ingredients, "IngredientId", "IngredientId", ingredientCategory.IngredientId);
            return(View(ingredientCategory));
        }
        /// <summary>
        /// Creates an <see cref="IngredientCategoryModel"/> instance from the given <see cref="IngredientCategory"/>.
        /// </summary>
        /// <param name="ingredientCategory">An ingredient category.</param>
        /// <returns>A read-only view of the given ingredient category.</returns>
        public static IngredientCategoryModel From(IngredientCategory ingredientCategory)
        {
            if (ingredientCategory == null)
            {
                return(null);
            }

            return(new IngredientCategoryModel()
            {
                Id = ingredientCategory.Id,
                Name = ingredientCategory.Name
            });
        }
Beispiel #12
0
        // GET: IngredientCategories/Delete/5
        public ActionResult Delete(int id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            IngredientCategory ingredientCategory = _ingredientCategoryService.GetById(id);

            if (ingredientCategory == null)
            {
                return(HttpNotFound());
            }
            return(View(ingredientCategory));
        }
Beispiel #13
0
        public static IEnumerable <IngredientCategory> GetDefaultCategories()
        {
            List <IngredientCategory> categories = new List <IngredientCategory>
            {
                IngredientCategory.Create("First Category"),
                IngredientCategory.Create("Second Category"),
                IngredientCategory.Create("Third Category"),
                IngredientCategory.Create("4th Category"),
                IngredientCategory.Create("5th Category"),
                IngredientCategory.Create("other-ingredients")
            };

            return(categories);
        }
Beispiel #14
0
        public async Task <IActionResult> OnGetAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            IngredientCategory = await _context.IngredientCategories.FirstOrDefaultAsync(m => m.IngredientCategoryID == id);

            if (IngredientCategory == null)
            {
                return(NotFound());
            }
            return(Page());
        }
Beispiel #15
0
        public void Valid_IngredientCategory_Create()
        {
            //Arrange
            IngredientCategory c = new IngredientCategory()
            {
                Name = "test1"
            };

            //Act
            var result = (RedirectToRouteResult)objController.Create(c);

            //Assert
            _ingredientCategoryServiceMock.Verify(m => m.Create(c), Times.Once);
            Assert.AreEqual("Index", result.RouteValues["action"]);
        }
Beispiel #16
0
        public void DeleteItemFromDataStore()
        {
            IngredientCategory removing = Context.IngredientCategories.First();

            Context.IngredientCategories.Delete(removing.Id);

            Context.SaveChanges();

            //Check save successful by opening new context and inspecting data

            NachoMaticContext newContext = new NachoMaticContext();

            bool itemGone = newContext.IngredientCategories.All(i => i.Name != removing.Name);

            Assert.IsTrue(itemGone);
        }
        public IHttpActionResult PostGroceryCategory(IngredientCategoryModel ingredientCategoryModel)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var ingredientCategory = new IngredientCategory();

            ObjectFactory.Parse(ingredientCategoryModel, ingredientCategory);

            _ingredientCategoryService.Add(ingredientCategory);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = ingredientCategory.Id }, ingredientCategory));
        }
Beispiel #18
0
        public void Invalid_IngredientCategory_Create()
        {
            // Arrange
            IngredientCategory c = new IngredientCategory()
            {
                Name = ""
            };

            objController.ModelState.AddModelError("Error", "Something went wrong");

            //Act
            var result = (ViewResult)objController.Create(c);

            //Assert
            _ingredientCategoryServiceMock.Verify(m => m.Create(c), Times.Never);
            Assert.AreEqual("", result.ViewName);
        }
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            IngredientCategory = await _context.IngredientCategories.FindAsync(id);

            if (IngredientCategory != null)
            {
                _context.IngredientCategories.Remove(IngredientCategory);
                await _context.SaveChangesAsync();
            }

            return(RedirectToPage("./Index"));
        }
        public static IngredientCategory Parse(IngredientCategoryModel model, IngredientCategory obj)
        {
            if (model == null)
            {
                return(null);
            }

            if (obj == null)
            {
                return(null);
            }

            obj.Id   = model.Id;
            obj.Name = model.Name;

            return(obj);
        }
        public async Task AddIngredientCustom(Guid recipeId, string categoryName, string measureUnit, string name,
                                              double quantity, double cost, double weight)
        {
            Ingredient ingredient;

            if (!await Exists(name, measureUnit))
            {
                Guid categoryId;
                if (!await _ingredientsCategoryRepository.Exists(categoryName))
                {
                    IngredientCategory igCat = IngredientCategory.Create(categoryName);
                    await _ingredientsCategoryRepository.Add(igCat);

                    categoryId = igCat.Id;
                }
                else
                {
                    categoryId = (await _ingredientsCategoryRepository.GetByName(categoryName)).Id;
                }
                double scale = IngredientsRepository.MapMeasurement["undefined"];
                if (IngredientsRepository.MapMeasurement.ContainsKey(measureUnit))
                {
                    scale = IngredientsRepository.MapMeasurement[measureUnit];
                }

                ingredient = Ingredient.Create(categoryId, name, measureUnit, cost * scale * weight / 10000000);
                await Add(ingredient);
                await UpdateIngredientsCategory(name, await GetSpecificCategory(name));
            }
            else
            {
                if (!categoryName.Equals("other-ingredients"))
                {
                    if (!await _ingredientsCategoryRepository.Exists(categoryName))
                    {
                        IngredientCategory igCat = IngredientCategory.Create(categoryName);
                        await _ingredientsCategoryRepository.Add(igCat);
                    }
                    await UpdateIngredientsCategory(name, (await _ingredientsCategoryRepository.GetByName(categoryName)).Id);
                }
                ingredient = await GetByNameAndMeasure(name, measureUnit);
            }
            await _fridgeRepository.Add(PairItem.Create(ingredient.Id, recipeId, quantity));
        }
        public Boolean UpdateIngredientsCategory(IngredientCategory IC)//IngredientCategory Object
        {
            INGREDIENT_CATEGORY result = (from p in db.INGREDIENT_CATEGORY
                                          where p.ID == IC.ICID
                                          select p).SingleOrDefault();

            result.NAME            = IC.Name;
            result.FRONTEND_ID     = IC.FrontendID;
            result.MANUFACTURER_ID = IC.ManufacturerID;
            try
            {
                db.SaveChanges();
                return(true);
            }

            catch (DbUpdateException ex)
            {
                return(false);
            }
        }
        public void GetByName_Should_Work_Ok()
        {
            RunOnDatabase(async s =>
            {
                DestroyDatabase();
                // Arrange
                var categoryRepo = new IngredientsCategoryRepository(s);
                IEnumerable <IngredientCategory> categories = GetDefaultCategories();

                // Act
                foreach (var ingredientCategory in categories)
                {
                    await categoryRepo.Add(ingredientCategory);
                }

                // Assert
                IngredientCategory ic = categoryRepo.GetByName("First Category").Result;
                Assert.AreEqual(ic.Id, categories.First().Id);
            });
        }
        public static void Seed(this ModelBuilder modelBuilder)
        {
            // Camps
            var straddy = new Camp {
                ID = Guid.NewGuid(), Name = "Stradbroke Cup"
            };
            var annual = new Camp {
                ID = Guid.NewGuid(), Name = "Annual Camp"
            };

            modelBuilder.Entity <Camp>().HasData(new List <Camp> {
                straddy, annual
            });

            // Equipment
            var pot = new Equipment {
                ID = Guid.NewGuid(), Name = "Pot (Large)"
            };

            modelBuilder.Entity <Equipment>().HasData(new List <Equipment> {
                pot
            });

            // Ingredient Categories
            var dairy = new IngredientCategory {
                IngredientCategoryID = Guid.NewGuid(), Name = "Dairy"
            };
            var pantry = new IngredientCategory {
                IngredientCategoryID = Guid.NewGuid(), Name = "Pantry"
            };
            var bakery = new IngredientCategory {
                IngredientCategoryID = Guid.NewGuid(), Name = "Bakery"
            };
            var meat = new IngredientCategory {
                IngredientCategoryID = Guid.NewGuid(), Name = "Meat"
            };
            var fresh = new IngredientCategory {
                IngredientCategoryID = Guid.NewGuid(), Name = "Fresh"
            };

            modelBuilder.Entity <IngredientCategory>().HasData(new List <IngredientCategory> {
                dairy, pantry, bakery, meat, fresh
            });

            // Recipes
            var hotC = new Recipe {
                ID = Guid.NewGuid(), Name = "Hot Chocolate"
            };
            var hotD = new Recipe {
                ID = Guid.NewGuid(), Name = "Hot Dogs"
            };

            modelBuilder.Entity <Recipe>().HasData(new List <Recipe> {
                hotC, hotD
            });

            // Menus
            var peckers = new Menu {
                ID = Guid.NewGuid(), CampID = straddy.ID, MenuName = "Peckers Patrol Menu", StartDate = new DateTime(2020, 3, 18), EndDate = new DateTime(2020, 3, 20)
            };

            modelBuilder.Entity <Menu>().HasData(new List <Menu> {
                peckers
            });

            // Meals
            var friSup = new Meal {
                ID = Guid.NewGuid(), Day = DayOfWeek.Friday, MealType = MealType.Supper, MenuID = peckers.ID
            };
            var satLunch = new Meal {
                ID = Guid.NewGuid(), Day = DayOfWeek.Saturday, MealType = MealType.Lunch, MenuID = peckers.ID
            };

            modelBuilder.Entity <Meal>().HasData(new List <Meal> {
                friSup, satLunch
            });

            // Ingredients
            var fcMilk = new Ingredient {
                ID = Guid.NewGuid(), Name = "Milk - Full Cream (UHT)", IngredientCategoryID = dairy.IngredientCategoryID, Unit = "Litre", UnitQuantity = 2, Perishable = true, Standard = true, Vegetarian = true, GlutenFree = true, LactoseFree = false, UnitCost = 2.00
            };
            var lfMilk = new Ingredient {
                ID = Guid.NewGuid(), Name = "Milk - Lactose Free (UHT) (LF)", IngredientCategoryID = dairy.IngredientCategoryID, Unit = "Litre", UnitQuantity = 2, Perishable = false, Standard = false, Vegetarian = false, GlutenFree = false, LactoseFree = true, UnitCost = 2.00
            };
            var hcPowder = new Ingredient {
                ID = Guid.NewGuid(), Name = "Hot Chocolate Powder", IngredientCategoryID = pantry.IngredientCategoryID, Unit = "Kilogram", UnitQuantity = 0.4, Perishable = false, Standard = true, Vegetarian = true, GlutenFree = true, LactoseFree = true, UnitCost = 4.00
            };
            var snags = new Ingredient {
                ID = Guid.NewGuid(), Name = "Sausages", IngredientCategoryID = meat.IngredientCategoryID, Unit = "Each", UnitQuantity = 1, Perishable = true, Standard = true, Vegetarian = false, GlutenFree = true, LactoseFree = true, UnitCost = 1.16
            };
            var veggieSnags = new Ingredient {
                ID = Guid.NewGuid(), Name = "Vegetarian Sausages", IngredientCategoryID = pantry.IngredientCategoryID, Unit = "Packet", UnitQuantity = 0.33, Perishable = true, Standard = false, Vegetarian = true, GlutenFree = false, LactoseFree = false, UnitCost = 6.00
            };
            var hotDogBuns = new Ingredient {
                ID = Guid.NewGuid(), Name = "Hot Dog Buns", IngredientCategoryID = bakery.IngredientCategoryID, Unit = "Each", UnitQuantity = 1, Perishable = true, Standard = true, Vegetarian = true, GlutenFree = false, LactoseFree = true, UnitCost = 2.00
            };
            var gfBread = new Ingredient {
                ID = Guid.NewGuid(), Name = "Gluten Free Bread (GF)", IngredientCategoryID = bakery.IngredientCategoryID, Unit = "Loaf", UnitQuantity = 1, Perishable = false, Standard = false, Vegetarian = false, GlutenFree = true, LactoseFree = false, UnitCost = 7.00
            };
            var tomatoSauce = new Ingredient {
                ID = Guid.NewGuid(), Name = "Tomato Sauce", IngredientCategoryID = pantry.IngredientCategoryID, Unit = "Bottle", UnitQuantity = 1, Perishable = false, Standard = true, Vegetarian = true, GlutenFree = true, LactoseFree = true, UnitCost = 4.00
            };
            var mustard = new Ingredient {
                ID = Guid.NewGuid(), Name = "Mustard", IngredientCategoryID = pantry.IngredientCategoryID, Unit = "Bottle", UnitQuantity = 1, Perishable = false, Standard = true, Vegetarian = true, GlutenFree = true, LactoseFree = true, UnitCost = 4.15
            };
            var bbq = new Ingredient {
                ID = Guid.NewGuid(), Name = "BBQ Sauce", IngredientCategoryID = pantry.IngredientCategoryID, Unit = "Bottle", UnitQuantity = 1, Perishable = false, Standard = true, Vegetarian = true, GlutenFree = true, LactoseFree = true, UnitCost = 4.00
            };

            modelBuilder.Entity <Ingredient>().HasData(new List <Ingredient> {
                fcMilk, lfMilk, hcPowder, snags, veggieSnags, hotDogBuns, gfBread, tomatoSauce, mustard, bbq
            });

            // Ingredient Entries
            modelBuilder.Entity <IngredientEntry>().HasData(new List <IngredientEntry>
            {
                new IngredientEntry {
                    IngredientID = fcMilk.ID, RecipeID = hotC.ID, QuantityNeeded = 0.20
                },
                new IngredientEntry {
                    IngredientID = lfMilk.ID, RecipeID = hotC.ID, QuantityNeeded = 0.20
                },
                new IngredientEntry {
                    IngredientID = hcPowder.ID, RecipeID = hotC.ID, QuantityNeeded = 0.045
                },
                new IngredientEntry {
                    IngredientID = snags.ID, RecipeID = hotD.ID, QuantityNeeded = 1.75
                },
                new IngredientEntry {
                    IngredientID = veggieSnags.ID, RecipeID = hotD.ID, QuantityNeeded = 1.75
                },
                new IngredientEntry {
                    IngredientID = hotDogBuns.ID, RecipeID = hotD.ID, QuantityNeeded = 2
                },
                new IngredientEntry {
                    IngredientID = gfBread.ID, RecipeID = hotD.ID, QuantityNeeded = 0.1
                },
                new IngredientEntry {
                    IngredientID = tomatoSauce.ID, RecipeID = hotD.ID, QuantityNeeded = 0.02
                },
                new IngredientEntry {
                    IngredientID = mustard.ID, RecipeID = hotD.ID, QuantityNeeded = 0.01
                },
                new IngredientEntry {
                    IngredientID = bbq.ID, RecipeID = hotD.ID, QuantityNeeded = 0.01
                },
            });

            // Meal Recipes
            modelBuilder.Entity <MealRecipe>().HasData(new List <MealRecipe>
            {
                new MealRecipe {
                    MealID = friSup.ID, RecipeID = hotC.ID
                },
                new MealRecipe {
                    MealID = satLunch.ID, RecipeID = hotD.ID
                }
            });

            // Recipe Equipments
            modelBuilder.Entity <RecipeEquipment>().HasData(new List <RecipeEquipment>
            {
                new RecipeEquipment {
                    RecipeID = hotC.ID, EquipmentID = pot.ID
                }
            });
        }
    private Ingredient(EnumIngredients aliment, string name, IngredientCategory category,
	                   string backgroundSpriteName, string ingredientSpriteName, string ingredientBottomSpriteName)
    {
        this.Aliment = aliment;
        m_name = name;
        m_category = category;
        m_backgroundSpriteName = backgroundSpriteName;
        m_ingredientSpriteName = ingredientSpriteName;
        m_ingredientShadowSpriteName = m_ingredientSpriteName.Replace(".png", "_shadow.png"); ;
        m_ingredientBottomSpriteName = ingredientBottomSpriteName ?? ingredientSpriteName;
    }
Beispiel #26
0
 public void Update(IngredientCategory ingredientCategory)
 {
     _db.Entry(ingredientCategory).State = EntityState.Modified;
 }
Beispiel #27
0
 public void Add(IngredientCategory ingredientCategory)
 {
     _db.IngredientCategories.Add(ingredientCategory);
 }
        private void InputDbContent()
        {
            bool               success = false;
            Customer           cust;
            Ingredient         ingr;
            IngredientCategory ic;
            Order              order;
            OrderItem          oi;
            Product            prod;

            SharedLibrary.Models.Recipe rec;
            //Package pack;
            //ReciepeIngredients ri;
            //SharedLibrary.Models.Rule rule;
            //RuleCategory rc;
            //SharedLibrary.Models.Shape shape;

            Console.WriteLine("Start DB Input");

            if (productInfo.TableList.Count > 0)
            {
                Console.WriteLine("Start input Product\nCount: " + productInfo.TableList.Count);

                foreach (var item in productInfo.TableList)
                {
                    prod = new Product();

                    if (item.BackendID == null)
                    {
                        prod.Product_ID          = (decimal)item.ProduktID;
                        prod.Product_Name        = item.Name;
                        prod.Product_Description = item.Description;
                        prod.Category            = item.Category;
                        prod.Product_Avail       = item.Availability;
                        prod.List_Price          = (decimal?)item.ListPrice;

                        prod.Product_Image = null;
                        prod.MIMETYPE      = "";
                        prod.Filename      = "";
                        prod.Tags          = "";

                        if (item.SalePrice != null)
                        {
                            prod.Sale_Price = (decimal?)item.SalePrice;
                        }

                        if (item.SaleBegin != null)
                        {
                            prod.Sale_Begin = item.SaleBegin;
                        }

                        if (item.SaleEnd != null)
                        {
                            prod.Sale_End = item.SaleEnd;
                        }

                        prod.Filename = item.Filename;

                        if (item.ProduktID != null)
                        {
                            prod.Manufaturer_ID = item.ProduktID;
                        }

                        if (item.FrontEndID != null)
                        {
                            prod.Frontend_ID = item.FrontEndID;
                        }

                        bdh.AddProduct(prod);
                        Console.WriteLine("Insert Product in DB");
                    }
                    else
                    {
                        prod.Product_ID          = (decimal)item.BackendID;
                        prod.Product_Name        = item.Name;
                        prod.Product_Description = item.Description;
                        prod.Category            = item.Category;
                        prod.Product_Avail       = item.Availability;
                        prod.List_Price          = (decimal?)item.ListPrice;

                        prod.Product_Image = null;
                        prod.MIMETYPE      = "";
                        prod.Filename      = "";
                        prod.Tags          = "";

                        if (item.SalePrice != null)
                        {
                            prod.Sale_Price = (decimal?)item.SalePrice;
                        }

                        if (item.SaleBegin != null)
                        {
                            prod.Sale_Begin = item.SaleBegin;
                        }

                        if (item.SaleEnd != null)
                        {
                            prod.Sale_End = item.SaleEnd;
                        }

                        prod.Filename = item.Filename;

                        if (item.ProduktID != null)
                        {
                            prod.Manufaturer_ID = item.ProduktID;
                        }

                        if (item.FrontEndID != null)
                        {
                            prod.Frontend_ID = item.FrontEndID;
                        }

                        success = bdh.UpdateProduct(prod, "MANUFACTURER");

                        if (success)
                        {
                            Console.WriteLine("DB Update Product executed");
                        }
                        else
                        {
                            Console.WriteLine("DB Update Product failed");
                        }
                    }
                }
            }

            if (customers.TableList.Count > 0)
            {
                Console.WriteLine("Start input Customers\nCount: " + customers.TableList.Count);

                foreach (var item in customers.TableList)
                {
                    cust = new Customer();

                    if (item.BackendID == null)
                    {
                        cust.CustomerId  = (decimal)item.Customer_ID;
                        cust.FirstName   = item.FirstName;
                        cust.LastName    = item.LastName;
                        cust.Address     = item.StreetAdress1;
                        cust.City        = item.City;
                        cust.State       = "";
                        cust.Zip         = item.PostalCode;
                        cust.Email       = item.Email;
                        cust.PhoneNumber = item.PhoneNumber1;
                        cust.Url         = "";
                        cust.CreditLimit = null;
                        cust.Tags        = "";

                        if (item.Customer_ID != null)
                        {
                            cust.Manufaturer_ID = item.Customer_ID;
                        }

                        if (item.FrontEndID != null)
                        {
                            cust.Frontend_ID = item.FrontEndID;
                        }

                        bdh.AddCustomer(cust);
                    }
                    else
                    {
                        cust.CustomerId  = (decimal)item.BackendID;
                        cust.FirstName   = item.FirstName;
                        cust.LastName    = item.LastName;
                        cust.Address     = item.StreetAdress1;
                        cust.City        = item.City;
                        cust.State       = "";
                        cust.Zip         = item.PostalCode;
                        cust.Email       = item.Email;
                        cust.PhoneNumber = item.PhoneNumber1;
                        cust.Url         = "";
                        cust.CreditLimit = null;
                        cust.Tags        = "";

                        if (item.Customer_ID != null)
                        {
                            cust.Manufaturer_ID = item.Customer_ID;
                        }

                        if (item.FrontEndID != null)
                        {
                            cust.Frontend_ID = item.FrontEndID;
                        }

                        success = bdh.UpdateCustomer(cust, "MANUFACTURER");

                        if (success)
                        {
                            Console.WriteLine("DB Update Customer executed");
                        }
                        else
                        {
                            Console.WriteLine("DB Update Customer failed");
                        }
                    }
                }
            }

            if (ingredientCategory.TableList.Count > 0)
            {
                Console.WriteLine("Start input IngredientCategory\nCount: " + ingredientCategory.TableList.Count);

                foreach (var item in ingredientCategory.TableList)
                {
                    ic = new IngredientCategory();

                    if (item.BackendID == null)
                    {
                        ic.ICID = (decimal)item.Id;
                        ic.Name = item.Name;

                        if (item.Id != null)
                        {
                            ic.ManufacturerID = item.Id;
                        }

                        if (item.FrontEndID != null)
                        {
                            ic.FrontendID = item.FrontEndID;
                        }

                        bdh.AddIngredientCategory(ic);
                    }
                    else
                    {
                        ic.ICID = (decimal)item.BackendID;
                        ic.Name = item.Name;

                        if (item.Id != null)
                        {
                            ic.ManufacturerID = item.Id;
                        }

                        if (item.FrontEndID != null)
                        {
                            ic.FrontendID = item.FrontEndID;
                        }

                        success = bdh.UpdateIngredientsCategory(ic);

                        if (success)
                        {
                            Console.WriteLine("DB Update IngredientsCategory executed");
                        }
                        else
                        {
                            Console.WriteLine("DB Update IngredientsCategory failed");
                        }
                    }
                }
            }

            if (ingredients.TableList.Count > 0)
            {
                Console.WriteLine("Start input Ingredients\nCount: " + ingredients.TableList.Count);

                foreach (var item in ingredients.TableList)
                {
                    ingr = new Ingredient();

                    if (item.BackendID == null)
                    {
                        ingr.IID              = (decimal)item.Id;
                        ingr.Price            = (decimal)item.Price;
                        ingr.Filename         = "";
                        ingr.MIMETYPE         = "";
                        ingr.Ingredient_Image = null;
                        ingr.Description      = item.Description;
                        ingr.Location_Top     = item.LocationTop;
                        ingr.Location_Bottom  = item.LocationBottom;
                        ingr.Location_Choc    = item.LocationChoc;
                        ingr.Name             = item.Name;
                        ingr.Quantity         = item.Quantity;
                        ingr.CategoryId       = (decimal)item.CategoryId;

                        if (item.Id != null)
                        {
                            ingr.ManufacturerID = item.Id;
                        }

                        if (item.FrontEndID != null)
                        {
                            ingr.FrontendID = item.FrontEndID;
                        }

                        bdh.AddIngredient(ingr);
                    }
                    else
                    {
                        ingr.IID              = (decimal)item.BackendID;
                        ingr.Price            = (decimal)item.Price;
                        ingr.Filename         = "";
                        ingr.MIMETYPE         = "";
                        ingr.Ingredient_Image = null;
                        ingr.Description      = item.Description;
                        ingr.Location_Top     = item.LocationTop;
                        ingr.Location_Bottom  = item.LocationBottom;
                        ingr.Location_Choc    = item.LocationChoc;
                        ingr.Name             = item.Name;
                        ingr.Quantity         = item.Quantity;
                        ingr.CategoryId       = (decimal)item.CategoryId;

                        if (item.Id != null)
                        {
                            ingr.ManufacturerID = item.Id;
                        }

                        if (item.FrontEndID != null)
                        {
                            ingr.FrontendID = item.FrontEndID;
                        }

                        success = bdh.UpdateIngredients(ingr);

                        if (success)
                        {
                            Console.WriteLine("DB Update Ingredients executed");
                        }
                        else
                        {
                            Console.WriteLine("DB Update Ingredients failed");
                        }
                    }
                }
            }

            if (orders.TableList.Count > 0)
            {
                Console.WriteLine("Start input Orders\nCount: " + orders.TableList.Count);

                foreach (var item in orders.TableList)
                {
                    order = new Order();

                    if (item.BackendID == null)
                    {
                        order.OrderId        = (decimal)item.OrdersID;
                        order.CustomerID     = bdh.GetOrderBID(item.CustomerID);
                        order.OrderTotal     = (decimal?)item.OrderTotal;
                        order.OrderTimeStamp = item.OrderTimeStamp;
                        order.UserName       = item.UserName;
                        order.Tags           = "";

                        if (item.OrdersID != null)
                        {
                            order.Manufaturer_ID = item.OrdersID;
                        }

                        if (item.FrontEndID != null)
                        {
                            order.Frontend_ID = item.FrontEndID;
                        }

                        bdh.AddOrder(order);
                    }
                    //else
                    //{
                    //    //ToDo: UpdateOrder?
                    //}
                }
            }

            if (orderItems.TableList.Count > 0)
            {
                Console.WriteLine("Start input OrdersItems\nCount: " + orderItems.TableList.Count);

                foreach (var item in orderItems.TableList)
                {
                    oi = new OrderItem();
                    if (item.BackendID == null)
                    {
                        oi.OrderItemID = (decimal)item.OrderItemID;
                        oi.OrderID     = bdh.GetOrderBID(item.OrderID);
                        oi.ProductID   = bdh.GetProductBID(item.ProductID);
                        oi.UnitPrice   = (decimal)item.UnitPrice;
                        oi.Quantity    = (int)item.Quantity;

                        if (item.OrderID != null)
                        {
                            oi.ManufacturerID = item.OrderItemID;
                        }

                        if (item.FrontEndID != null)
                        {
                            oi.FrontEndID = item.FrontEndID;
                        }

                        bdh.AddOrderItem(oi);
                    }
                    //else
                    //{
                    //    //ToDo: UpdateOrderItem?
                    //}
                }
            }

            if (recipe.TableList.Count > 0)
            {
                Console.WriteLine("Start input Recipes\nCount: " + recipe.TableList.Count);

                foreach (var item in recipe.TableList)
                {
                    rec = new SharedLibrary.Models.Recipe();
                    if (item.BackendID == null)
                    {
                        rec.RID         = (decimal)item.Id;
                        rec.ProductID   = bdh.GetProductBID(item.ProductId);
                        rec.Description = item.Description;

                        if (item.Id != null)
                        {
                            rec.ManufacturerID = item.Id;
                        }

                        if (item.FrontEndID != null)
                        {
                            rec.FrontendID = item.FrontEndID;
                        }

                        rec.Last_Updated    = DateTime.Now;
                        rec.Last_Updated_By = "MANUFACTURER";

                        bdh.AddRecipe(rec);
                    }
                    else
                    {
                        rec.RID         = (decimal)item.BackendID;
                        rec.ProductID   = bdh.GetProductBID(item.ProductId);
                        rec.Description = item.Description;

                        if (item.Id != null)
                        {
                            rec.ManufacturerID = item.Id;
                        }

                        if (item.FrontEndID != null)
                        {
                            rec.FrontendID = item.FrontEndID;
                        }

                        success = bdh.UpdateRecipe(rec, "MANUFACTURER");

                        if (success)
                        {
                            Console.WriteLine("DB Update Recipe executed");
                        }
                        else
                        {
                            Console.WriteLine("DB Update Recipe failed");
                        }
                    }
                }
            }

            //ToDo: DB fuctions for Package, RecipeIngedients, Rule, RuleCategory, Shape
            Console.WriteLine("DB Input finished");
        }