Ejemplo n.º 1
0
        public ActionResult Category(Type type)
        {
            switch (type)
            {
            case Type.Tour:
                var ViewedList = new List <TourView>();
                using (var context = new TourContext())
                {
                    foreach (Tour tour in context.Tour)
                    {
                        ViewedList.Add(new TourView(tour));
                    }
                }
                return(View("Tours", ViewedList.AsEnumerable <TourView>()));

            case Type.Bus:
                List <BusView> BusList = new List <BusView>();
                using (var context = new BusContext())
                {
                    foreach (Bus bus in context.Bus)
                    {
                        BusList.Add(new BusView(bus));
                    }
                }
                return(View("Buses", BusList));
            }
            return(View());
        }
Ejemplo n.º 2
0
        static List <image> GetImagesForTour(tour t)
        {
            TourContext  db     = new TourContext();
            List <image> result = (from image in db.images where image.IdTour == t.IdTour select image).ToList <image>();

            return(result);
        }
Ejemplo n.º 3
0
        static List <image> GetImagesForCity(city c)
        {
            TourContext  db     = new TourContext();
            List <image> result = (from image in db.images where image.IdCity == c.IdCity select image).ToList <image>();

            return(result);
        }
Ejemplo n.º 4
0
        static List <image> GetImagesForCategory(tourcategory cat)
        {
            TourContext  db     = new TourContext();
            List <image> result = (from image in db.images where image.IdTourCategory == cat.IdTourCategory select image).ToList <image>();

            return(result);
        }
Ejemplo n.º 5
0
 public ActionResult Tour(int Id)
 {
     using (TourContext context = new TourContext())
     {
         var toutview = new TourView(context.Tour.FirstOrDefault(t => t.ID == Id));
         return(View("Tour", toutview));
     }
 }
Ejemplo n.º 6
0
 public AdminController(QuantitySevice quantitySevice, TravelService travelService,
                        IHostingEnvironment hostingEnvironment, TourContext db,
                        StaffService staffService)
 {
     this._staffService       = staffService;
     this._hostingEnvironment = hostingEnvironment;
     this._quantitySevice     = quantitySevice;
     this._travelService      = travelService;
     this._db = db;
 }
Ejemplo n.º 7
0
        public static List <CountryInfo> GetCountries()
        {
            TourContext        db     = new TourContext();
            List <CountryInfo> result = new List <CountryInfo>();

            foreach (country c in db.countries)
            {
                CountryInfo nCountry = new CountryInfo(c);
                result.Add(nCountry);
            }
            return(result);
        }
Ejemplo n.º 8
0
        private string GetLocations()
        {
            using var context = new TourContext(serviceProvider.GetRequiredService <DbContextOptions <TourContext> >());
            List <Location> locations = context.Locations.ToList();
            string          result    = "";

            foreach (Location location in locations)
            {
                result += "Id: " + location.LocationID + " ,Name: " + location.Name + " ,Descriptions: " + location.Description + "\n";
            }
            return(result);
        }
Ejemplo n.º 9
0
        public string GetTours()
        {
            using var context = new TourContext(serviceProvider.GetRequiredService <DbContextOptions <TourContext> >());
            List <Tour> tours  = context.Tours.ToList();
            string      result = "";

            foreach (Tour tour in tours)
            {
                result += "Name: " + tour.Name + ", Type: " + tour.Type.Label + " ,MinDuration: " + tour.MinDuration + "\n";
            }
            return(result);
        }
Ejemplo n.º 10
0
        public void AddTours()
        {
            using var context = new TourContext(serviceProvider.GetRequiredService <DbContextOptions <TourContext> >());

            Console.WriteLine("Enter tour name: ");
            string name = Console.ReadLine();

            Console.WriteLine("How many locations you want to add into the tour:");
            int count = 0;

            try
            {
                count = Convert.ToInt32(Console.ReadLine());
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                count = Convert.ToInt32(Console.ReadLine());
            }

            List <Location> locations = new List <Location>();

            for (int i = 0; i < count; i++)
            {
                Console.WriteLine($"Add the {i + 1} location's Id");
                int id = Convert.ToInt32(Console.ReadLine());
                locations.Add(context.Locations.Find(id));
            }

            Tour tour = new Tour
            {
                Name       = name,
                TourTypeID = 1//seed item for console app
            };

            List <Location_Tour> lcs = new List <Location_Tour>();

            foreach (Location location in locations)
            {
                var Location_Tour = new Location_Tour
                {
                    TourID     = tour.TourID,
                    LocationID = location.LocationID
                };
                context.LocationSets.Add(Location_Tour);
                lcs.Add(Location_Tour);
            }
            tour.Location_Tour = lcs;
            tour.MinDuration   = tour.caculateMinDuration();

            context.Tours.Add(tour);
            context.SaveChanges();
        }
Ejemplo n.º 11
0
        public static List <TourCategoryInfo> GetCategories()
        {
            TourContext             db     = new TourContext();
            List <TourCategoryInfo> result = new List <TourCategoryInfo>();

            foreach (tourcategory cat in db.tourcategories)
            {
                TourCategoryInfo nCat = new TourCategoryInfo(cat.IdTourCategory);
                result.Add(nCat);
            }
            return(result);
        }
Ejemplo n.º 12
0
        public async Task <bool> Login(int ID, string password)
        {
            using var context = new TourContext(serviceProvider.GetRequiredService <DbContextOptions <TourContext> >());
            var login = await context.Logins.FindAsync(ID);

            if (login == null || !PBKDF2.Verify(login.PasswordHash, password) || login.ActivationStatus == false)
            {
                return(false);
            }
            else
            {
                return(true);
            }
        }
Ejemplo n.º 13
0
        public static List <TourInfo> GetListTourByCategory(int idCategory)
        {
            TourContext     db           = new TourContext();
            List <TourInfo> result       = new List <TourInfo>();
            tourcategory    tourCategory = db.tourcategories.Find(idCategory);
            List <tour>     tours        = tourCategory.tours.ToList <tour>();

            foreach (tour t in tours)
            {
                TourInfo nTourInfo = new TourInfo(t.IdTour);
                result.Add(nTourInfo);
            }
            return(result);
        }
Ejemplo n.º 14
0
        public static List <CityInfo> GetListCityByCountry(int idCountry)
        {
            TourContext     db     = new TourContext();
            List <CityInfo> result = new List <CityInfo>();
            country         c      = db.countries.Find(idCountry);
            List <city>     cities = (from city in db.cities where city.IdСountry == c.IdСountry select city).ToList <city>();

            foreach (city city in cities)
            {
                CityInfo nCityInfo = new CityInfo(city.IdCity);
                result.Add(nCityInfo);
            }
            return(result);
        }
Ejemplo n.º 15
0
        public void RemoveTour()
        {
            using var context = new TourContext(serviceProvider.GetRequiredService <DbContextOptions <TourContext> >());
            Console.WriteLine("Enter the tour ID you want to remove:");
            int Id = 0;

            try
            {
                Id = Convert.ToInt32(Console.ReadLine());
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                Id = Convert.ToInt32(Console.ReadLine());
            }

            context.Tours.Remove(context.Tours.Find(Id));
            context.SaveChanges();
        }
Ejemplo n.º 16
0
        public void RemoveLocatonAsync()
        {
            using var context = new TourContext(serviceProvider.GetRequiredService <DbContextOptions <TourContext> >());
            Console.WriteLine("Enter the tour Location you want to remove:");
            int Id = 0;

            try
            {
                Id = Convert.ToInt32(Console.ReadLine());
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                Id = Convert.ToInt32(Console.ReadLine());
            }

            context.LocationSets.RemoveRange(context.LocationSets.Where(e => e.Location.LocationID == Id));
            context.Locations.Remove(context.Locations.Find(Id));
            context.SaveChanges();
        }
Ejemplo n.º 17
0
        public static List <ImageInfo> GetImagesForElem(string typeElem, int idElem)
        {
            TourContext      db     = new TourContext();
            List <ImageInfo> result = new List <ImageInfo>();
            List <image>     images = new List <image>();

            switch (typeElem)
            {
            case "category":
            {
                tourcategory cat = db.tourcategories.Find(idElem);
                images = GetImagesForCategory(cat);
                break;
            }

            case "tour":
            {
                tour t = db.tours.SingleOrDefault <tour>(m => m.IdTour == idElem);
                images = GetImagesForTour(t);
                break;
            }

            case "city":
            {
                city c = db.cities.SingleOrDefault <city>(m => m.IdCity == idElem);
                images = GetImagesForCity(c);
                break;
            }
            }
            foreach (image im in images)
            {
                ImageInfo nImageInfo = new ImageInfo(im);
                result.Add(nImageInfo);
            }
            return(result);
        }
Ejemplo n.º 18
0
 public BookingService(TourContext db, TourService tourService)
 {
     this._db          = db;
     this._tourService = tourService;
 }
Ejemplo n.º 19
0
 public TourService(TourContext db)
 {
     this._db = db;
 }
Ejemplo n.º 20
0
 public NhanVienRepository(TourContext context)
 {
     _context = context;
 }
Ejemplo n.º 21
0
        /* public Client()
         * {
         *    _ContextClient = new PeopleContext();
         * }
         */

        public ClientManager(TourContext context)
        {
            _ContextClient = context;
        }
Ejemplo n.º 22
0
 public ChiTieuRepository(TourContext context)
 {
     _context = context;
 }
Ejemplo n.º 23
0
 public MemberService(TourContext tourContext)
 {
     this._db = tourContext;
 }
Ejemplo n.º 24
0
 public HomeController(TourContext db, MemberService memberService)
 {
     this._db            = db;
     this._memberService = memberService;
 }
Ejemplo n.º 25
0
 public ToursController(TourContext context)
 {
     _context = context;
 }
Ejemplo n.º 26
0
 public TourController(TourService tourService, TourContext db)
 {
     this._db          = db;
     this._tourService = tourService;
 }
Ejemplo n.º 27
0
 public StaffService(TourContext db)
 {
     this._db = db;
 }
Ejemplo n.º 28
0
 public TravelService(TourContext db, IHostingEnvironment hostingEnvironment)
 {
     this._db = db;
     this._hostingEnvironment = hostingEnvironment;
 }
Ejemplo n.º 29
0
 public HanhKhachRepository(TourContext context)
 {
     _context = context;
 }
Ejemplo n.º 30
0
 public TourRepository(TourContext context) : base(context)
 {
     _context = context;
 }