示例#1
0
        public static void stdOutXML(PortDBViewModel DB_VM)
        {
            Console.WriteLine("Kategóriák:\n");
            foreach (var c in DB_VM.Categories)
            {
                Console.WriteLine(c.Id + " " + c.Name);
            }

            Console.WriteLine("\nAlkategóriák:");
            foreach (var s in DB_VM.Subcategories)
            {
                Console.WriteLine(s.Id + " " + s.Name + " " + s.CategoryId);
            }

            Console.WriteLine("\nÉtelek:");
            foreach (var f in DB_VM.Foods)
            {
                Console.WriteLine(f.ID + " "
                                  + f.Name + " "
                                  + f.CategoryId + " "
                                  + f.SubCategoryId + " "
                                  + f.Description + " "
                                  + f.BestBefore + " "
                                  + f.Unit + " "
                                  + f.QuantityLeft + " "
                                  + f.Measurement);
            }
        }
示例#2
0
        private void DumpDataToXML(PortDBViewModel DB_VM)
        {
            XDocument xmlDocument     = XMLSerializerFromDB(DB_VM);
            string    filename        = "Data_" + DateTime.Now.ToShortDateString().Replace('.', '_').Replace(' ', '_') + ".xml";
            string    XMLFileToExport = Path.Combine(env.WebRootPath, "Data", filename);

            xmlDocument.Save(XMLFileToExport);
        }
        //public PortDBViewModel ImportXML()
        public void ImportXML()
        {
            PortDBViewModel originalParsedXML = Testing.ParseXML(Testing.XMLinPath);
            PortDBViewModel normalizedXml     = Testing.normalizeIDs(originalParsedXML);

            Testing.AddManyCategoriesFromParamToDBTest(normalizedXml.Categories);
            Testing.AddManySubCategoriesFromParamToDBTest(normalizedXml.Subcategories);
            Testing.AddManyFoodItemFromParamToDBTest(normalizedXml.Foods);
        }
示例#4
0
        public void ImportXML()
        {
            //PortDBViewModel originalParsedXML = ParseXML(SD.XMLinPath);
            PortDBViewModel originalParsedXML = ParseXML(XMLFileDynamicPath);
            PortDBViewModel normalizedXml     = normalizeIDs(originalParsedXML);

            AddManyCategoriesFromParamToDBTest(normalizedXml.Categories);
            AddManySubCategoriesFromParamToDBTest(normalizedXml.Subcategories);
            AddManyFoodItemFromParamToDBTest(normalizedXml.Foods);
        }
示例#5
0
        public static PortDBViewModel RemoveIDToDB(PortDBViewModel input)
        {
            //removing IDs for DB-identity
            List <Category>    newCategories2DB    = new List <Category>();
            List <SubCategory> newsubCategories2DB = new List <SubCategory>();
            List <Food>        newFoods2DB         = new List <Food>();

            //removing ID from category class
            foreach (var categitem in input.Categories)
            {
                Category newcatitem = new Category();
                newcatitem.Name = categitem.Name;
                newCategories2DB.Add(newcatitem);
            }

            // removing ID from subcategory
            foreach (var subcategitem in input.Subcategories)
            {
                SubCategory newsubcatitem = new SubCategory
                {
                    Name       = subcategitem.Name,
                    CategoryId = subcategitem.CategoryId
                };
                newsubCategories2DB.Add(newsubcatitem);
            }

            //removind ID from Foods
            foreach (var fooditem in input.Foods)
            {
                Food newFooditem = new Food
                {
                    Name          = fooditem.Name,
                    Description   = fooditem.Description,
                    CategoryId    = fooditem.CategoryId,
                    SubCategoryId = fooditem.SubCategoryId,
                    BestBefore    = fooditem.BestBefore,
                    Unit          = fooditem.Unit,
                    Measurement   = fooditem.Measurement,
                    QuantityLeft  = fooditem.QuantityLeft
                };
                newFoods2DB.Add(newFooditem);
            }

            PortDBViewModel output = new PortDBViewModel
            {
                Categories    = newCategories2DB,
                Subcategories = newsubCategories2DB,
                Foods         = newFoods2DB
            };

            return(output);
        }
示例#6
0
        public PortDBViewModel Get()
        {
            List <Category>           CategoryItems    = applicationDbContext.Category.ToList();
            IEnumerable <SubCategory> SubCategoryItems = applicationDbContext.SubCategory.ToList();
            IEnumerable <Food>        FoodItems        = applicationDbContext.Foods.ToList();

            PortDBViewModel DB_VM = new PortDBViewModel
            {
                Categories    = CategoryItems,
                Subcategories = SubCategoryItems,
                Foods         = FoodItems
            };

            return(DB_VM);
        }
        public IActionResult Export()
        {
            List <Category>           CategoryItems    = applicationDbContext.Category.ToList();
            IEnumerable <SubCategory> SubCategoryItems = applicationDbContext.SubCategory.ToList();
            IEnumerable <Food>        FoodItems        = applicationDbContext.Foods.ToList();

            PortDBViewModel DB_VM = new PortDBViewModel
            {
                Categories    = CategoryItems,
                Subcategories = SubCategoryItems,
                Foods         = FoodItems
            };

            //PortDBViewModel normalized_DB_VM = ImportExportData.normalizeIDs(DB_VM);
            //ImportExportData.DumpDataToXML(DB_VM);

            //dm.ExportXML(DB_VM);
            ImpExpMan.ExportXML(DB_VM);
            return(RedirectToAction("Index", "Home", new { area = "User" }));
        }
示例#8
0
        public XDocument XMLSerializerFromDB(PortDBViewModel DB_VM)
        {
            XDocument xmlDocument = new XDocument(
                new XDeclaration("1.0", "utf-8", "yes"),
                new XComment("Creating an XML Tree using LINQ to XML"),

                new XElement("Foods",
                             new XElement("Categories",
                                          from category in DB_VM.Categories
                                          select new XElement("Category",
                                                              new XElement("CategoryID", category.Id),
                                                              new XElement("Name", category.Name)
                                                              )),

                             new XElement("Subcategories",
                                          from subcategory in DB_VM.Subcategories
                                          select new XElement("Subcategory",
                                                              new XElement("SubcategoryID", subcategory.Id),
                                                              new XElement("Name", subcategory.Name),
                                                              new XElement("CategoryID", subcategory.CategoryId)
                                                              )),

                             new XElement("FoodItems",
                                          from foodItem in DB_VM.Foods
                                          select new XElement("FoodItem",
                                                              new XElement("FoodID", foodItem.ID),
                                                              new XElement("Name", foodItem.Name),
                                                              new XElement("Description", foodItem.Description),
                                                              new XElement("CategoryID", foodItem.CategoryId),
                                                              new XElement("SubcategoryId", foodItem.SubCategoryId),
                                                              new XElement("BestBefore", null),
                                                              new XElement("Unit", 0),
                                                              new XElement("Measurement", foodItem.Measurement),
                                                              new XElement("QuanityLeft", QuantityLeft.Semennyi)
                                                              ))
                             ));

            return(xmlDocument);
        }
示例#9
0
        private PortDBViewModel ParseXML(string XMLPath)
        {
            PortDBViewModel DB_VM = new PortDBViewModel();

            XDocument doc = XDocument.Load(XMLPath);
            IEnumerable <Category> categories = from c in doc.Descendants("Category")
                                                select new Category()
            {
                Id   = (int)c.Element("CategoryID"),
                Name = (string)c.Element("Name")
            };

            IEnumerable <SubCategory> subCategories = from s in doc.Descendants("Subcategory")
                                                      select new SubCategory()
            {
                Id         = (int)s.Element("SubcategoryID"),
                Name       = (string)s.Element("Name"),
                CategoryId = (int)s.Element("CategoryID")
            };

            IEnumerable <Food> Foods = from f in doc.Descendants("FoodItem")
                                       select new Food()
            {
                ID            = (int)f.Element("FoodID"),
                Name          = (string)f.Element("Name"),
                Description   = (string)f.Element("Description"),
                CategoryId    = (int)f.Element("CategoryID"),
                SubCategoryId = (int)f.Element("SubcategoryId"),
                BestBefore    = string.IsNullOrEmpty((string)f.Element("BestBefore")) ? (DateTime?)null : (DateTime)f.Element("BestBefore"),
                Unit          = (int)f.Element("Unit"),
                QuantityLeft  = Enum.Parse <QuantityLeft>((string)f.Element("QuanityLeft")),
                Measurement   = Enum.Parse <MeasType>((string)f.Element("Measurement"))
            };

            DB_VM.Categories    = categories;
            DB_VM.Subcategories = subCategories;
            DB_VM.Foods         = Foods;
            return(DB_VM);
        }
示例#10
0
        private void DumpDataToXML(PortDBViewModel DB_VM)
        {
            XDocument xmlDocument = new XDocument(
                new XDeclaration("1.0", "utf-8", "yes"),
                new XComment("Creating an XML Tree using LINQ to XML"),

                new XElement("Foods",
                             new XElement("Categories",
                                          from category in DB_VM.Categories
                                          select new XElement("Category",
                                                              new XElement("CategoryID", category.Id),
                                                              new XElement("Name", category.Name)
                                                              )),

                             new XElement("Subcategories",
                                          from subcategory in DB_VM.Subcategories
                                          select new XElement("Subcategory",
                                                              new XElement("SubcategoryID", subcategory.Id),
                                                              new XElement("Name", subcategory.Name),
                                                              new XElement("CategoryID", subcategory.CategoryId)
                                                              )),

                             new XElement("FoodItems",
                                          from foodItem in DB_VM.Foods
                                          select new XElement("FoodItem",
                                                              new XElement("FoodID", foodItem.ID),
                                                              new XElement("Name", foodItem.Name),
                                                              new XElement("Description", foodItem.Description),
                                                              new XElement("CategoryID", foodItem.CategoryId),
                                                              new XElement("SubcategoryId", foodItem.SubCategoryId),
                                                              new XElement("BestBefore", foodItem.BestBefore),
                                                              new XElement("Unit", foodItem.Unit),
                                                              new XElement("Measurement", foodItem.Measurement),
                                                              new XElement("QuanityLeft", foodItem.QuantityLeft)
                                                              ))
                             ));

            xmlDocument.Save(XMLinPath);
        }
示例#11
0
        public void TestNormalize_Categ_Subcateg_AndDependencies()
        {
            PortDBViewModel originalDBV = new PortDBViewModel()
            {
                Categories = new List <TestCategory>
                {
                    new TestCategory {
                        Id = 1, Name = "Elso"
                    },
                },
                Subcategories = new List <TestSubcategory>
                {
                    new TestSubcategory {
                        Id = 2, Name = "Elso", CategoryId = 1
                    },
                    new TestSubcategory {
                        Id = 5, Name = "Masodik", CategoryId = 1
                    },
                    new TestSubcategory {
                        Id = 6, Name = "Harmadik", CategoryId = 1
                    },
                },
                Foods = new List <TestFood>
                {
                    new TestFood {
                        ID = 1, Name = "Elso", CategoryId = 1, SubCategoryId = 5
                    },
                }
            };

            PortDBViewModel normalizedDBM = Testing.normalizeIDs(originalDBV);

            PortDBViewModel expectedDBM = new PortDBViewModel()
            {
                Categories = new List <TestCategory>
                {
                    new TestCategory {
                        Id = 0, Name = "Elso"
                    },
                },
                Subcategories = new List <TestSubcategory>
                {
                    new TestSubcategory {
                        Id = 0, Name = "Elso", CategoryId = 1
                    },
                    new TestSubcategory {
                        Id = 0, Name = "Masodik", CategoryId = 1
                    },
                    new TestSubcategory {
                        Id = 0, Name = "Harmadik", CategoryId = 1
                    },
                },
                Foods = new List <TestFood>
                {
                    new TestFood {
                        ID = 0, Name = "Elso", CategoryId = 1, SubCategoryId = 2
                    },
                }
            };

            Assert.Equal(expectedDBM.Categories, normalizedDBM.Categories);
            Assert.Equal(expectedDBM.Subcategories, normalizedDBM.Subcategories);
            Assert.Equal(expectedDBM.Foods, normalizedDBM.Foods);
        }
示例#12
0
        public void TestNormalize_Mes2_Categ_SubCateg_Food_AndDependencies()
        {
            PortDBViewModel originalDBV = new PortDBViewModel()
            {
                Categories = new List <TestCategory>
                {
                    new TestCategory {
                        Id = 7, Name = "Fagyasztó"
                    },
                    new TestCategory {
                        Id = 8, Name = "Spejz"
                    },
                    new TestCategory {
                        Id = 9, Name = "Hűtő"
                    }
                },
                Subcategories = new List <TestSubcategory>
                {
                    new TestSubcategory {
                        Id = 2, Name = "Húsok", CategoryId = 9
                    },
                    new TestSubcategory {
                        Id = 5, Name = "Tejtemék", CategoryId = 9
                    },
                    new TestSubcategory {
                        Id = 6, Name = "Zöldség", CategoryId = 9
                    },
                    new TestSubcategory {
                        Id = 7, Name = "Mirelit Gyümölcs", CategoryId = 7
                    },
                    new TestSubcategory {
                        Id = 8, Name = "Félkész ételek", CategoryId = 7
                    },
                    new TestSubcategory {
                        Id = 10, Name = "Konzerv", CategoryId = 8
                    },
                    new TestSubcategory {
                        Id = 11, Name = "Tartós zöldség", CategoryId = 8
                    },
                    new TestSubcategory {
                        Id = 13, Name = "Olajok, mártások, szószok", CategoryId = 8
                    },
                    new TestSubcategory {
                        Id = 14, Name = "Gyümölcs", CategoryId = 9
                    },
                    new TestSubcategory {
                        Id = 15, Name = "Zöldség", CategoryId = 7
                    },
                    new TestSubcategory {
                        Id = 16, Name = "Gabonafélék", CategoryId = 8
                    },
                    new TestSubcategory {
                        Id = 17, Name = "Fűszerek", CategoryId = 8
                    },
                    new TestSubcategory {
                        Id = 18, Name = "Disznósajt", CategoryId = 9
                    },
                },
                Foods = new List <TestFood>
                {
                    new TestFood {
                        ID = 10, Name = "Kolbász", CategoryId = 9, SubCategoryId = 2
                    },
                    new TestFood {
                        ID = 11, Name = "Padlizsán", CategoryId = 9, SubCategoryId = 6
                    },
                    new TestFood {
                        ID = 12, Name = "barack", CategoryId = 9, SubCategoryId = 14
                    },
                    new TestFood {
                        ID = 13, Name = "Rántott sajt", CategoryId = 7, SubCategoryId = 8
                    },
                    new TestFood {
                        ID = 14, Name = "Kelbimbó", CategoryId = 7, SubCategoryId = 15
                    },
                    new TestFood {
                        ID = 15, Name = "Dobozos Tej", CategoryId = 9, SubCategoryId = 5
                    },
                    new TestFood {
                        ID = 16, Name = "Sajt", CategoryId = 9, SubCategoryId = 5
                    },
                    new TestFood {
                        ID = 17, Name = "Kenyér", CategoryId = 8, SubCategoryId = 16
                    },
                    new TestFood {
                        ID = 18, Name = "Kifli", CategoryId = 8, SubCategoryId = 16
                    },
                    new TestFood {
                        ID = 19, Name = "OIiva olaj", CategoryId = 8, SubCategoryId = 13
                    },
                    new TestFood {
                        ID = 20, Name = "Túró Rudi", CategoryId = 9, SubCategoryId = 5
                    },
                    new TestFood {
                        ID = 21, Name = "Meggy", CategoryId = 7, SubCategoryId = 7
                    },
                    new TestFood {
                        ID = 22, Name = "Szilva", CategoryId = 7, SubCategoryId = 7
                    },
                    new TestFood {
                        ID = 23, Name = "Zalai", CategoryId = 9, SubCategoryId = 2
                    },
                }
            };

            PortDBViewModel normalizedDBM = Testing.normalizeIDs(originalDBV);

            PortDBViewModel expectedDBM = new PortDBViewModel()
            {
                Categories = new List <TestCategory>
                {
                    new TestCategory {
                        Id = 0, Name = "Fagyasztó"
                    },
                    new TestCategory {
                        Id = 0, Name = "Spejz"
                    },
                    new TestCategory {
                        Id = 0, Name = "Hűtő"
                    }
                },
                Subcategories = new List <TestSubcategory>
                {
                    new TestSubcategory {
                        Id = 0, Name = "Húsok", CategoryId = 3
                    },
                    new TestSubcategory {
                        Id = 0, Name = "Tejtemék", CategoryId = 3
                    },
                    new TestSubcategory {
                        Id = 0, Name = "Zöldség", CategoryId = 3
                    },
                    new TestSubcategory {
                        Id = 0, Name = "Mirelit Gyümölcs", CategoryId = 1
                    },
                    new TestSubcategory {
                        Id = 0, Name = "Félkész ételek", CategoryId = 1
                    },
                    new TestSubcategory {
                        Id = 0, Name = "Konzerv", CategoryId = 2
                    },
                    new TestSubcategory {
                        Id = 0, Name = "Tartós zöldség", CategoryId = 2
                    },
                    new TestSubcategory {
                        Id = 0, Name = "Olajok, mártások, szószok", CategoryId = 2
                    },
                    new TestSubcategory {
                        Id = 0, Name = "Gyümölcs", CategoryId = 3
                    },
                    new TestSubcategory {
                        Id = 0, Name = "Zöldség", CategoryId = 1
                    },
                    new TestSubcategory {
                        Id = 0, Name = "Gabonafélék", CategoryId = 2
                    },
                    new TestSubcategory {
                        Id = 0, Name = "Fűszerek", CategoryId = 2
                    },
                    new TestSubcategory {
                        Id = 0, Name = "Disznósajt", CategoryId = 3
                    },
                },
                Foods = new List <TestFood>
                {
                    new TestFood {
                        ID = 0, Name = "Kolbász", CategoryId = 3, SubCategoryId = 1
                    },
                    new TestFood {
                        ID = 0, Name = "Padlizsán", CategoryId = 3, SubCategoryId = 3
                    },
                    new TestFood {
                        ID = 0, Name = "barack", CategoryId = 3, SubCategoryId = 9
                    },
                    new TestFood {
                        ID = 0, Name = "Rántott sajt", CategoryId = 1, SubCategoryId = 5
                    },
                    new TestFood {
                        ID = 0, Name = "Kelbimbó", CategoryId = 1, SubCategoryId = 10
                    },
                    new TestFood {
                        ID = 0, Name = "Dobozos Tej", CategoryId = 3, SubCategoryId = 2
                    },
                    new TestFood {
                        ID = 0, Name = "Sajt", CategoryId = 3, SubCategoryId = 2
                    },
                    new TestFood {
                        ID = 0, Name = "Kenyér", CategoryId = 2, SubCategoryId = 11
                    },
                    new TestFood {
                        ID = 0, Name = "Kifli", CategoryId = 2, SubCategoryId = 11
                    },
                    new TestFood {
                        ID = 0, Name = "OIiva olaj", CategoryId = 2, SubCategoryId = 8
                    },
                    new TestFood {
                        ID = 0, Name = "Túró Rudi", CategoryId = 3, SubCategoryId = 2
                    },
                    new TestFood {
                        ID = 0, Name = "Meggy", CategoryId = 1, SubCategoryId = 4
                    },
                    new TestFood {
                        ID = 0, Name = "Szilva", CategoryId = 1, SubCategoryId = 4
                    },
                    new TestFood {
                        ID = 0, Name = "Zalai", CategoryId = 3, SubCategoryId = 1
                    },
                }
            };

            Assert.Equal(expectedDBM.Categories, normalizedDBM.Categories);
            Assert.Equal(expectedDBM.Subcategories, normalizedDBM.Subcategories);
            Assert.Equal(expectedDBM.Foods, normalizedDBM.Foods);
        }
示例#13
0
 //private const string XMLinPath = @"C:\Users\Szabolcs\Source\Repos\FoodTracker\FoodTracker\FoodTracker\Port\DataToImport.xml";
 public void ExportXML(PortDBViewModel input)
 {
     DumpDataToXML(input);
 }
示例#14
0
        private PortDBViewModel normalizeIDs(PortDBViewModel input)
        {
            //Initialize data counts
            int CategoryCount    = input.Categories.Count();
            int SubCategoryCount = input.Subcategories.Count();
            int FoodItemsCount   = input.Foods.Count();

            List <Category>    Categories2DB    = input.Categories.ToList();
            List <SubCategory> SubCategories2DB = input.Subcategories.ToList();
            List <Food>        Foods2DB         = input.Foods.ToList();

            //Normalize subcategory.CategoryId to new Category.ID
            //1. Take all Categories
            for (int i = 0; i < CategoryCount; i++)
            {
                //2. Check all subcategories
                foreach (var subcategory in SubCategories2DB)
                {
                    //if an "old" subcategory.categID mathes and "old" Category.ID... (foreign key ref.)
                    if (subcategory.CategoryId == Categories2DB[i].Id)
                    {
                        //replace subcateg.Categ by the index number+1 of the categ
                        // (cf. categ index+1 value will be the new ID in the new "clean" DB).
                        subcategory.CategoryId = i + 1;
                    }
                }
            }

            //normalize the food.SubCategoryId to new SubCategory.ID
            //1. Take all Subcategories
            for (int i = 0; i < SubCategoryCount; i++)
            {
                //2. iterate all foods
                foreach (var food in Foods2DB)
                {
                    //3. if an "old" food.subcategID matches the "old" subcateg.id (foreign key ref.)
                    if (food.SubCategoryId == SubCategories2DB[i].Id)
                    {
                        //4. replace the food.subcateg with the index+1 (index+1 will be
                        //the new subcat.ID in the "clean" DB).
                        food.SubCategoryId = i + 1;
                    }
                }
            }

            //normalize the Food.Category to new Category.ID
            //1. Take all categories
            for (int i = 0; i < CategoryCount; i++)
            {
                //2. Iterate through all the foods
                foreach (var food in Foods2DB)
                {
                    //3. if an "old" food.Category mathes the "old" category.ID (foreign key ref.)
                    if (food.CategoryId == Categories2DB[i].Id)
                    {
                        //4. update food.CategID with index+1 (cycle index+1 will be the new Categ.ID)
                        food.CategoryId = i + 1;
                        //5. set all food.ID to 0 (EF can then insert it to DB)
                        food.ID = 0;
                    }
                }
            }

            //set all Category ID to 0 (EF can then insert it to DB)
            foreach (var item in Categories2DB)
            {
                item.Id = 0;
            }

            //set all Subcategory ID to 0 (EF can then insert it to DB)
            foreach (var item in SubCategories2DB)
            {
                item.Id = 0;
            }

            PortDBViewModel output = new PortDBViewModel
            {
                Categories    = Categories2DB,
                Subcategories = SubCategories2DB,
                Foods         = Foods2DB
            };

            return(output);
        }
示例#15
0
        public static PortDBViewModel normalizeIDs(PortDBViewModel input)
        {
            //Initialize data counts
            int CategoryCount    = input.Categories.Count();
            int SubCategoryCount = input.Subcategories.Count();
            int FoodItemsCount   = input.Foods.Count();

            //data cloning
            List <Category>    newCategories    = input.Categories.ToList();
            List <SubCategory> newsubCategories = input.Subcategories.ToList();
            List <Food>        newFoods         = input.Foods.ToList();
            int newIndex = 1;


            //Distinct original values of Categ/Subcateg
            var OriginalCategoryIds    = input.Categories.GroupBy(c => c.Id).ToList();
            var OriginalSubCategoryIds = input.Subcategories.GroupBy(s => s.Id).ToList();


            //Normalize Category.ID
            foreach (var categIDToChange in OriginalCategoryIds)
            {
                foreach (var category in newCategories)
                {
                    if (category.Id == categIDToChange.Key)
                    {
                        category.Id = newIndex;
                        newIndex++;
                        break;
                    }
                }
            }

            newIndex = 1;
            //Normalize Subcategory.ID
            foreach (var subcategIDToChange in OriginalSubCategoryIds)
            {
                foreach (var subcategory in newsubCategories)
                {
                    if (subcategory.Id == subcategIDToChange.Key)
                    {
                        subcategory.Id = newIndex;
                        newIndex++;
                        break;
                    }
                }
            }


            //Normalize subcategory.CategoryId
            for (int i = 0; i < CategoryCount; i++)
            {
                foreach (var subcategory in newsubCategories)
                {
                    if (subcategory.CategoryId == OriginalCategoryIds[i].Key)
                    {
                        subcategory.CategoryId = newCategories[i].Id;
                    }
                }
            }

            //normalize the food.SubCategoryId
            for (int i = 0; i < SubCategoryCount; i++)
            {
                foreach (var food in newFoods)
                {
                    if (food.SubCategoryId == OriginalSubCategoryIds[i].Key)
                    {
                        food.SubCategoryId = newsubCategories[i].Id;
                    }
                }
            }

            //normalize the Food.CategoryID
            for (int i = 0; i < CategoryCount; i++)
            {
                foreach (var food in newFoods)
                {
                    if (food.CategoryId == OriginalCategoryIds[i].Key)
                    {
                        food.CategoryId = newCategories[i].Id;
                    }
                }
            }

            PortDBViewModel output = new PortDBViewModel
            {
                Categories    = newCategories,
                Subcategories = newsubCategories,
                Foods         = newFoods
            };

            return(output);
        }
        private void DumpDataToXML(PortDBViewModel DB_VM)
        {
            XDocument xmlDocument = XMLSerializerFromDB(DB_VM);

            xmlDocument.Save(XMLFileDynamicPath);
        }