public static Resturant_Library.Resturant DataResturanttoLibraryResturant(DataLibrary.Resturant dataset)
        {
            var libmodel = new Resturant_Library.Resturant() // converting information from the database for the resturant library to understand
            {
                Name          = dataset.Name,
                Id            = dataset.id,
                AverageRating = dataset.AverageRating,
                City          = dataset.City,
                State         = dataset.State,
                Street        = dataset.Street
            };

            return(libmodel);
        }
Beispiel #2
0
        public Resturant FindRestByID(int id)
        {
            Resturant returnrest         = null;
            IEnumerable <Resturant> Find = db.Resturants.ToList();

            foreach (var item in Find)
            {
                if (item.id == id)
                {
                    returnrest = item;
                    // tell the db to grab the reviews for that item
                }
            }
            if (returnrest == null)
            {
                Console.WriteLine("no resturant");
            }
            return(returnrest);
        }
Beispiel #3
0
        public void SelectionHandler()
        {
            int ReviewSelection;

            converted = (List <Resturant_Library.Resturant>)sorts.sorterconvert(cs.ShowResturants());
            while ((ReviewSelection = GetReviewSelection()) != 6)
            {
                switch (ReviewSelection)
                {
                case 1:
                    converted = (List <Resturant_Library.Resturant>)sorts.ShowResturantsbyRating(converted);
                    foreach (var list1 in list)
                    {
                        Console.WriteLine(list1.AverageRating + " " + list1.Name);
                    }
                    break;

                case 2:
                    foreach (var name1 in converted)
                    {
                        Console.WriteLine(name1.Name + " ");
                    }
                    break;

                case 3:
                    Console.WriteLine("Enter Id of Resturant");
                    int id = int.Parse(Console.ReadLine());
                    DataLibrary.Resturant rest = cs.FindRestByID(id);
                    try
                    {
                        Console.WriteLine(rest.id);
                        Console.WriteLine(rest.Name);
                        Console.WriteLine(rest.City);
                        Console.WriteLine(rest.State);
                        Console.WriteLine(rest.Street);
                        Console.WriteLine(rest.AverageRating);
                    }
                    catch
                    {
                        Console.WriteLine("That ID does not exist");
                        log.Error($"{id} that ID does not Exist");
                    }
                    break;

                case 4:
                    Console.WriteLine("Enter Id of Resturant");
                    int i = int.Parse(Console.ReadLine());
                    DataLibrary.Resturant restr = cs.FindRestByID(i);
                    try
                    {
                        foreach (var rev1 in restr.ResturantReviews)
                        {
                            Console.WriteLine(rev1.Review_ID + " " + rev1.ReviewComment);
                        }
                    }
                    catch
                    {
                        Console.WriteLine("There is no ID for that Resturant");
                        log.Error($"{i} does not exist as a Resturant ID");
                    }
                    break;

                case 5:
                    Console.WriteLine("Enter the Resturant Name");
                    string ResturantName = Console.ReadLine();

                    {
                        converted = (List <Resturant_Library.Resturant>)sorts.FindResturantbyName(converted, ResturantName);
                        //if (sorts.(by))
                        //{
                        foreach (var rest1 in converted)
                        {
                            Console.WriteLine(rest1.Id + " " + rest1.Name);
                        }
                        //}
                        //else
                        //{
                        //    Console.WriteLine("There is no Resturant by that name");
                        //    log.Error($"{ResturantName} Does not Exist");
                        //}

                        break;
                    }
                }
            }
        }