Exemple #1
0
        private MaterialCount CreateMaterialCount(List <Material> materials)
        {
            Console.WriteLine("Pick a material> ");
            var hasElements = CommonClientFunctions.EntitySelection(materials, out Material material);

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

            Console.Write("Enter a description (Optional)> ");
            string newDescription = Console.ReadLine();

            decimal newUnitCount;

            do
            {
                Console.Write("Enter the number of units of material needed as a whole number> ");
                Decimal.TryParse(Console.ReadLine(), out newUnitCount);
            } while (newUnitCount <= 0);

            return(new MaterialCount()
            {
                MaterialId = material.Id,
                MaterialUnitCount = newUnitCount,
                Description = newDescription
            });
        }
Exemple #2
0
        private void UpdateItem()
        {
            Console.WriteLine("Pick an Item to Edit");
            var items       = CommonClientFunctions.ReadItems();
            var hasElements = CommonClientFunctions.EntitySelection(items, out Item item);

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

            Console.Write($"Name ({item.Name})> ");
            var newName = Console.ReadLine();

            Console.Write($"Name ({item.Description})> ");
            var newDescription = Console.ReadLine();

            item.Name        = String.IsNullOrWhiteSpace(newName) ? item.Name : newName;
            item.Description = String.IsNullOrWhiteSpace(newDescription) ? item.Description : newDescription;

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

            CommonClientFunctions.Menuing(MenuOptionsUpdateItemSizeOption(), (actionInput) =>
            {
                switch (actionInput)
                {
                case 1:
                    CreateSizeOption(item);
                    break;

                case 2:
                    UpdateSizeOption(item);
                    break;

                case 3:
                    DeleteSizeOption(item);
                    break;
                }
            });
        }
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 DeleteColor(Material material)
        {
            var colors      = CommonClientFunctions.ReadColorsByMaterialId(material.Id);
            var hasElements = CommonClientFunctions.EntitySelection(colors, out Color color, 1);

            if (!hasElements)
            {
                Console.WriteLine("No Colors Available");
                return;
            }
            if (color is null)
            {
                return;
            }
            using (var db = new ShopContext())
            {
                new DataService(db).Delete(color);
            }
        }
Exemple #5
0
        private void DeleteSizeOption(Item item)
        {
            var options     = CommonClientFunctions.ReadSizeOptionsByItemId(item.Id);
            var hasElements = CommonClientFunctions.EntitySelection(options, out SizeOption option, 1);

            if (!hasElements)
            {
                Console.WriteLine("No Size Options Available");
                return;
            }
            if (option is null)
            {
                return;
            }

            using (var db = new ShopContext())
            {
                new DataService(db).Delete(option);
            }
        }
Exemple #6
0
        private void DeleteMaterialCount(SizeOption option)
        {
            var materialCounts = CommonClientFunctions.ReadMaterialCountsBySizeOptionId(option.Id);
            var hasElements    = CommonClientFunctions.EntitySelection(materialCounts, out MaterialCount materialCount, 1);

            if (!hasElements)
            {
                Console.WriteLine("No Material Counts Available");
                return;
            }
            if (materialCount is null)
            {
                return;
            }

            using (var db = new ShopContext())
            {
                new DataService(db).Delete(materialCount);
            }
        }
Exemple #7
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);
            }
        }
Exemple #8
0
        private void UpdateColors(Material material)
        {
            var colors = material.Colors;

            var hasElements = CommonClientFunctions.EntitySelection(colors, out Color color, 1);

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

            Console.Write($"Name ({color.Name})> ");
            var newColorName = Console.ReadLine();

            Console.Write($"Color Code ({color.ColorCode})> ");
            var newColorCode = Console.ReadLine();

            Console.Write($"Cost ({color.Cost})> ");
            var pInput = Console.ReadLine();

            if (String.IsNullOrWhiteSpace(pInput))
            {
                pInput = "-1";
            }
            Int32.TryParse(pInput, out int newCost);

            color.Name      = String.IsNullOrWhiteSpace(newColorName) ? color.Name : newColorName;
            color.ColorCode = String.IsNullOrWhiteSpace(newColorCode) ? color.ColorCode : newColorCode;
            color.Cost      = newCost == -1 ? color.Cost : newCost;

            using (var db = new ShopContext())
            {
                new DataService(db).Update(color);
            }
        }
Exemple #9
0
        private void DeleteItem()
        {
            Console.WriteLine("Pick an Item to Delete");
            var items = CommonClientFunctions.ReadItems();

            var hasElements = CommonClientFunctions.EntitySelection(items, out Item item);

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

            using (var db = new ShopContext())
            {
                new DataService(db).Delete(item);
            }
        }
Exemple #10
0
        private void EditMaterialCount(SizeOption option)
        {
            var materialCounts = option.MaterialCounts;

            var hasElements = CommonClientFunctions.EntitySelection(materialCounts, out MaterialCount materialCount, 1);

            if (!hasElements)
            {
                Console.WriteLine("No Material Counts Available");
                return;
            }
            if (materialCount is null)
            {
                return;
            }

            Console.Write($"Description ({materialCount.Description})> ");
            string newDescription = Console.ReadLine();

            Console.Write($"Count ({materialCount.MaterialUnitCount})> ");
            var pInput = Console.ReadLine();

            if (String.IsNullOrWhiteSpace(pInput))
            {
                pInput = "-1";
            }
            Decimal.TryParse(pInput, out decimal newCount);

            materialCount.MaterialUnitCount = newCount == -1 ? materialCount.MaterialUnitCount : newCount;
            materialCount.Description       = String.IsNullOrWhiteSpace(newDescription) ? materialCount.Description : newDescription;

            using (var db = new ShopContext())
            {
                new DataService(db).Update(materialCount);
            }
        }
Exemple #11
0
        public void UpdateSizeOption(Item item)
        {
            var options     = item.SizeOptions;
            var hasElements = CommonClientFunctions.EntitySelection(options, out SizeOption option, 1);

            if (!hasElements)
            {
                Console.WriteLine("No Size Options Available");
                return;
            }
            if (option is null)
            {
                return;
            }

            Console.Write($"Size ({option.Size})> ");
            var newSize = Console.ReadLine();

            decimal newPrice;
            string  priceInput;

            do
            {
                newPrice = -1;
                Console.Write($"Price ({option.Price})> ");
                priceInput = Console.ReadLine().Replace("$", "");

                if (String.IsNullOrWhiteSpace(priceInput))
                {
                    break;
                }
                Decimal.TryParse(priceInput, out newPrice);
            } while (newPrice <= 0);

            int    newTTM;
            string timeInput;

            do
            {
                newTTM = -1;
                Console.Write($"Time To Make In Hours. Must be Non Zero. ({option.TimeToMakeInHours})> ");
                timeInput = Console.ReadLine();
                if (String.IsNullOrWhiteSpace(timeInput))
                {
                    break;
                }
                Int32.TryParse(timeInput, out newTTM);
            } while (newTTM <= 0);

            option.Size              = String.IsNullOrWhiteSpace(newSize) ? option.Size : newSize;
            option.Price             = newPrice == -1 ? option.Price : newPrice;
            option.TimeToMakeInHours = newTTM == -1 ? option.TimeToMakeInHours : newTTM;

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

            CommonClientFunctions.Menuing(MenuOptionsUpdateSizeOptionMaterialCount(), (actionInput) =>
            {
                switch (actionInput)
                {
                case 1:
                    CreateMaterialCount(option);
                    break;

                case 2:
                    EditMaterialCount(option);
                    break;

                case 3:
                    DeleteMaterialCount(option);
                    break;
                }
            });
        }