示例#1
0
        public static List <Tour> GetAllTours()//todo - check if this should be static. read when to use static
        {
            List <Tour> lst = null;

            using (ToursDBContext db = new ToursDBContext())
            {
                lst = (from tour in db.Tours select tour).ToList();
            }
            return(lst);
        }
示例#2
0
        public static List <tourCategory> getAllTourCategories()
        {
            List <tourCategory> lst = null;

            using (ToursDBContext db = new ToursDBContext())
            {
                lst = (from tourCategory in db.tourCategories select tourCategory).ToList();
            }

            return(lst);
        }
示例#3
0
        public static List <Tour> getToursByCategoryID(int categoryID)
        {
            List <Tour> lst = null;

            using (ToursDBContext db = new ToursDBContext())
            {
                // lst = (from Tour in db.Tours where Tour.CategoryID == categoryID select Tour).ToList();
                lst = db.Tours.Where(t => t.CategoryID == categoryID).ToList();
            }

            return(lst);
        }
示例#4
0
        public static int GetTourPriceByTourClassId(int id)
        {
            int price = 0;

            using (ToursDBContext db = new ToursDBContext())
            {
                var tourClass = db.tourClasses.FirstOrDefault(x => x.ClassID == id);
                if (tourClass != null)
                {
                    price = tourClass.ClassPrice;
                }
            }
            return(price);
        }
示例#5
0
        public static string GetCategoryNameById(int id)
        {
            var name = string.Empty;

            using (ToursDBContext db = new ToursDBContext())
            {
                var category = db.tourCategories.FirstOrDefault(x => x.CategoryId == id);
                if (category != null)
                {
                    name = category.CategoryName;
                }
            }
            return(name);
        }