Esempio n. 1
0
        public static string ReturnWatchString(int WatchId, int WatchType)
        {
            WatchCatalog watchCatalog = new WatchCatalog();

            if (WatchType == 1)
            {
                var item = watchCatalog.GetAnalogWatchById(WatchId);
                if (item == null)
                {
                    return("");
                }
                return($"Id - {item.WatchId}, Brand - {item.BrandName}, StrapType - {item.StrapType}, StrapColor - {item.StrapColor}, Price - {item.Price}, Segment - {item.Segment}, No.of.Hands - {item.NumberOfHands.ToString()}, HasCalendar - {item.HasCalender.ToString()}\n");
            }
            else if (WatchType == 2)
            {
                var item = watchCatalog.GetDigitalWatchById(WatchId);
                if (item == null)
                {
                    return("");
                }
                return($"Id - {item.WatchId}, Brand - {item.BrandName}, StrapType - {item.StrapType}, StrapColor - {item.StrapColor}, Price - {item.Price}, Segment - {item.Segment}, DisplayMode - {item.DisplayMode.ToString()}, HasBackLight - {item.HasBackLight.ToString()}\n");
            }

            return("");
        }
Esempio n. 2
0
        public void WatchCatalogShouldReturnAListOfWatch()
        {
            WatchCatalog watchCatalog = new WatchCatalog();

            Assert.NotNull(watchCatalog.Catalog);
            Assert.IsAssignableFrom <List <Watch> >(watchCatalog.Catalog);
            Assert.True(watchCatalog.Catalog.Count == 0);
        }
Esempio n. 3
0
 /// <summary>
 /// Getting order based on catalog
 /// </summary>
 /// <returns></returns>
 public static bool GettingOrder(string userName)
 {
     try
     {
         ClearScreen();
         GettingWatchList(userName);
         WatchCatalog watchCatalog = new WatchCatalog();
         Console.WriteLine($"Hi {userName}, Choose your catalog here. Press 1 - Analog Watch, 2 - Digital Watch, For Exit press any key...!!!");
         string catalogType = Console.ReadLine();
         if (catalogType == "1")
         {
             var AnalogList = watchCatalog.AnalogCatalog();
             Console.WriteLine("Here your available analog watches!!!!!!");
             foreach (var item in AnalogList)
             {
                 Console.WriteLine($"Id - {item.WatchId}, Brand - {item.BrandName}, StrapType - {item.StrapType}, StrapColor - {item.StrapColor}, Price - {item.Price}, Segment - {item.Segment}, No.of.Hands - {item.NumberOfHands.ToString()}, HasCalendar - {item.HasCalender.ToString()}\n");
             }
             Console.WriteLine("Select Watch Id to Process Order!!!");
             int    id       = 0;
             string WatchId  = Console.ReadLine();
             var    newId    = int.TryParse(WatchId, out id);
             bool   isPlaced = ProcessOrder(id, userName, 1);
             if (!isPlaced)
             {
                 return(false);
             }
         }
         else if (catalogType == "2")
         {
             var DigitalList = watchCatalog.DigitalCatalog();
             Console.WriteLine("Here your available digital watches!!!!!!");
             foreach (var item in DigitalList)
             {
                 Console.WriteLine($"Id - {item.WatchId}, Brand - {item.BrandName}, StrapType - {item.StrapType}, StrapColor - {item.StrapColor}, Price - {item.Price}, Segment - {item.Segment}, DisplayMode - {item.DisplayMode.ToString()}, HasBackLight - {item.HasBackLight.ToString()}\n");
             }
             Console.WriteLine("Select Watch Id to Process Order!!!");
             int    id       = 0;
             string WatchId  = Console.ReadLine();
             var    newId    = int.TryParse(WatchId, out id);
             bool   isPlaced = ProcessOrder(id, userName, 2);
             if (!isPlaced)
             {
                 return(false);
             }
         }
         else
         {
             throw new InvalidCatalogTypeException(catalogType);
         }
         return(true);
     }
     catch (InvalidCatalogTypeException ex)
     {
         Console.WriteLine(ex.Message);
         return(false);
     }
 }
Esempio n. 4
0
        private static void StartApp()
        {
            Console.WriteLine("Wacth Type Options: ");
            PrintWatchTypeMenu();
            Console.WriteLine("BrandName Options: ");
            BrandTypeMenu();
            Console.WriteLine("StrapType Options: ");
            StripeTypeMenu();
            Console.WriteLine("StrapColor Options: ");
            StripColorMenu();
            Console.WriteLine("Segment Options: ");
            SegmentColorMenu();

            var catalog = new WatchCatalog();

            catalog.Catalog = new List <Watch> {
                new AnalogWatch()
                {
                    WatchId = 1101, BrandName = "FASTTRACK", StrapType = "METALIC", StrapColor = "BLACK", Segment = "BASIC", Price = 4000, NumberOfHands = 2, HasCalender = false
                },
                new AnalogWatch()
                {
                    WatchId = 1102, BrandName = "FASTTRACK", StrapType = "METALIC", StrapColor = "BLACK", Segment = "BASIC", Price = 4000
                },
                new AnalogWatch()
                {
                    WatchId = 1103, BrandName = "FASTTRACK", StrapType = "METALIC", StrapColor = "BLACK", Segment = "BASIC", Price = 4000
                },
                new AnalogWatch()
                {
                    WatchId = 1104, BrandName = "FASTTRACK", StrapType = "METALIC", StrapColor = "BLACK", Segment = "BASIC", Price = 4000
                },
                new DigitalWatch()
                {
                    WatchId = 1105, BrandName = "FASTTRACK", StrapType = "METALIC", StrapColor = "BLACK", Segment = "BASIC", Price = 4000
                },
            };
            //var WatchCartApp = new WatchCartApp( new WatchService(new WatchRepository( new WatchCatalog())), new OrderRepository( new WatchStoreDbContext()));
            var WatchCartApp = new WatchCartApp(new WatchService(new WatchRepository(catalog)), new OrderRepository(new WatchStoreDbContext()));

            try
            {
                var Watch = WatchCartApp.GetWatchByUserChoice();

                Console.WriteLine("********************************************************");
                Console.WriteLine("Press 1 to Process order else press any key to Exit");

                int userChoice = Convert.ToInt32(Console.ReadLine());

                if (userChoice == 1)
                {
                    WatchCartApp.ProcessOrder(Watch);
                }
                else
                {
                    System.Environment.Exit(0);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            finally
            {
            }
        }