Exemple #1
0
        private void CreateSizeOption(Item item)
        {
            List <Material> materials  = CommonClientFunctions.ReadMaterials();
            var             sizeOption = CreateSizeOption(materials);

            sizeOption.ItemId = item.Id;
            item.SizeOptions.Add(sizeOption);
            using var db = new ShopContext();
            new DataService(db).Create(sizeOption);
        }
Exemple #2
0
        private void CreateItem()
        {
            List <Material> materials = CommonClientFunctions.ReadMaterials();

            if (materials.Count == 0)
            {
                Console.WriteLine("There must be materials created prior to making an item");
                return;
            }
            Console.Write("Enter Item Name> ");
            string name = Console.ReadLine();

            Console.Write("Enter Item Description> ");
            string description = Console.ReadLine();

            List <SizeOption> sizeOptions = new List <SizeOption>();

            Console.WriteLine("Enter Sizing Information.");
            do
            {
                var sizeOption = CreateSizeOption(materials);
                if (sizeOption is null)
                {
                    return;
                }
                sizeOptions.Add(sizeOption);

                Console.Write("Enter another sizing option? (\"yes\" or \"no\")> ");
                string cont = Console.ReadLine();

                if (!cont.ToLowerInvariant().Equals("yes"))
                {
                    break;
                }
            } while (true);

            Item newItem = new Item()
            {
                Name        = name,
                Description = description,
                SizeOptions = sizeOptions
            };

            using (var db = new ShopContext())
            {
                new DataService(db).Create(newItem);
            }
        }
Exemple #3
0
        private void UpdateMaterials()
        {
            Console.WriteLine("Pick a Material to Edit");
            var materials   = CommonClientFunctions.ReadMaterials();
            var hasElements = CommonClientFunctions.EntitySelection(materials, out Material material);

            if (!hasElements)
            {
                Console.WriteLine("No Materials Available");
                return;
            }
            if (material is null)
            {
                return;
            }

            Console.Write($"Name ({material.FullMaterialName})> ");
            var newFullMaterialName = Console.ReadLine();

            Console.Write($"Name ({material.FriendlyName})> ");
            var newFriendlyName = Console.ReadLine();

            material.FullMaterialName = String.IsNullOrWhiteSpace(newFullMaterialName) ? material.FullMaterialName : newFullMaterialName;
            material.FriendlyName     = String.IsNullOrWhiteSpace(newFriendlyName) ? material.FriendlyName : newFriendlyName;

            using (var db = new ShopContext())
            {
                new DataService(db).Update(material);
            }

            CommonClientFunctions.Menuing(MenuOptionsUpdateMaterials(), (actionInput) =>
            {
                switch (actionInput)
                {
                case 1:
                    CreateColor(material);
                    break;

                case 2:
                    UpdateColors(material);
                    break;

                case 3:
                    DeleteColor(material);
                    break;
                }
            });
        }
Exemple #4
0
        private void CreateMaterialCount(SizeOption option)
        {
            List <Material> materials = CommonClientFunctions.ReadMaterials();

            var materialCount = CreateMaterialCount(materials);

            if (materialCount is null)
            {
                return;
            }

            materialCount.SizeOptionId = option.Id;
            option.MaterialCounts.Add(materialCount);
            using var db = new ShopContext();
            new DataService(db).Create(materialCount);
        }
Exemple #5
0
        private void DeleteMaterial()
        {
            Console.WriteLine("Pick a Material to Delete");
            var materials   = CommonClientFunctions.ReadMaterials();
            var hasElements = CommonClientFunctions.EntitySelection(materials, out Material material);

            if (!hasElements)
            {
                Console.WriteLine("No Materials Available");
                return;
            }
            if (material is null)
            {
                return;
            }

            using (var db = new ShopContext())
            {
                new DataService(db).Delete(material);
            }
        }