private void ItemsReport()
        {
            var items = CommonClientFunctions.ReadItems();

            foreach (var item in items)
            {
                Console.WriteLine($"Item: {item.Name}");
                foreach (var sizeOption in item.SizeOptions)
                {
                    Console.WriteLine($"\tSize Option: {sizeOption.Size} - " +
                                      $"Sell Price: {sizeOption.Price.ToString("C", CultureInfo.CurrentCulture)} - " +
                                      $"{sizeOption.TimeToMakeInHours} hours");

                    //lowest cost materials
                    var minMaterialCost = new List <Tuple <decimal, decimal> >();
                    var maxMaterialCost = new List <Tuple <decimal, decimal> >();
                    var avgMaterialCost = new List <Tuple <decimal, decimal> >();

                    bool hasMaterialColors = false;
                    foreach (var materialCount in sizeOption.MaterialCounts)
                    {
                        var materialColorCosts = materialCount.Material.Colors.Select(c => c.Cost);
                        if (materialColorCosts.Count() == 0)
                        {
                            continue;
                        }
                        hasMaterialColors = true;
                        minMaterialCost.Add(new Tuple <decimal, decimal>(materialCount.MaterialUnitCount, materialColorCosts.Min()));
                        maxMaterialCost.Add(new Tuple <decimal, decimal>(materialCount.MaterialUnitCount, materialColorCosts.Max()));
                        avgMaterialCost.Add(new Tuple <decimal, decimal>(materialCount.MaterialUnitCount, materialColorCosts.Average()));
                    }
                    if (!hasMaterialColors)
                    {
                        continue;
                    }
                    var anserv = new AnalysisService();

                    var highestProfit = anserv.CalculateProfit(sizeOption, minMaterialCost);
                    var lowestProfit  = anserv.CalculateProfit(sizeOption, maxMaterialCost);
                    var averageProfit = anserv.CalculateProfit(sizeOption, avgMaterialCost);

                    Console.WriteLine($"\t\tMinimum Profit: {CommonClientFunctions.ConvertToMoney(lowestProfit)} - " +
                                      $"Minimum Profit Per Hour: {CommonClientFunctions.ConvertToMoney(anserv.ValuePerHour(sizeOption.TimeToMakeInHours, lowestProfit))}");

                    Console.WriteLine($"\t\tMaximum Profit: {CommonClientFunctions.ConvertToMoney(highestProfit)} - " +
                                      $"Maximum Profit Per Hour: {CommonClientFunctions.ConvertToMoney(anserv.ValuePerHour(sizeOption.TimeToMakeInHours, highestProfit))}");

                    Console.WriteLine($"\t\tAverage Profit: {CommonClientFunctions.ConvertToMoney(averageProfit)} - " +
                                      $"Average Profit Per Hour: {CommonClientFunctions.ConvertToMoney(anserv.ValuePerHour(sizeOption.TimeToMakeInHours, averageProfit))}");
                }
            }
        }
Beispiel #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;
                }
            });
        }
Beispiel #3
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);
            }
        }