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()); }
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); }
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); }
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); }
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)); } }
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; }
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); }
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); }
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); }
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(); }
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); }
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); } }
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); }
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); }
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(); }
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(); }
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); }
public BookingService(TourContext db, TourService tourService) { this._db = db; this._tourService = tourService; }
public TourService(TourContext db) { this._db = db; }
public NhanVienRepository(TourContext context) { _context = context; }
/* public Client() * { * _ContextClient = new PeopleContext(); * } */ public ClientManager(TourContext context) { _ContextClient = context; }
public ChiTieuRepository(TourContext context) { _context = context; }
public MemberService(TourContext tourContext) { this._db = tourContext; }
public HomeController(TourContext db, MemberService memberService) { this._db = db; this._memberService = memberService; }
public ToursController(TourContext context) { _context = context; }
public TourController(TourService tourService, TourContext db) { this._db = db; this._tourService = tourService; }
public StaffService(TourContext db) { this._db = db; }
public TravelService(TourContext db, IHostingEnvironment hostingEnvironment) { this._db = db; this._hostingEnvironment = hostingEnvironment; }
public HanhKhachRepository(TourContext context) { _context = context; }
public TourRepository(TourContext context) : base(context) { _context = context; }