Esempio n. 1
0
        public bool UpdateHotel(Hotel hotel)
        {
            try
            {
                using (MSTDCEntities dbContext = new MSTDCEntities())
                {
                    var hotel1 = dbContext.Hotels.Find(hotel.Hotel_ID);
                    hotel1.Hotel_ID          = hotel.Hotel_ID;
                    hotel1.Hotel_Name        = hotel.Hotel_Name;
                    hotel1.Hotel_Address     = hotel.Hotel_Address;
                    hotel1.No_Of_Rooms       = hotel.No_Of_Rooms;
                    hotel1.Place_ID          = hotel.Place_ID;
                    hotel1.Category          = hotel.Category;
                    hotel1.Hotel_Description = hotel.Hotel_Description;
                    hotel1.Image_Url         = hotel.Image_Url;
                    dbContext.SaveChanges();

                    return(true);
                }
            }
            catch (Exception e)
            {
                return(false);
            }
        }
Esempio n. 2
0
        public bool AddCity(City city)
        {
            try
            {
                using (MSTDCEntities dbContext = new MSTDCEntities())
                {
                    dbContext.Cities.Add(city);
                    dbContext.SaveChanges();
                }

                return(true);
            }
            catch (Exception ex)
            {
                return(false);
            }
        }
Esempio n. 3
0
        public bool AddHotel(Hotel hotel)
        {
            try
            {
                using (MSTDCEntities dbContext = new MSTDCEntities())
                {
                    dbContext.Hotels.Add(hotel);
                    dbContext.SaveChanges();
                }

                return(true);
            }
            catch (Exception ex)
            {
                return(false);
            }
        }
Esempio n. 4
0
        public bool AddPlace(Place place)
        {
            try
            {
                using (MSTDCEntities dbContext = new MSTDCEntities())
                {
                    dbContext.Places.Add(place);
                    dbContext.SaveChanges();
                }

                return(true);
            }
            catch (Exception ex)
            {
                return(false);
            }
        }
Esempio n. 5
0
        public List <City> ViewAllCities()
        {
            List <City> cityList = new List <City>();

            try
            {
                using (MSTDCEntities DbContext = new MSTDCEntities())
                {
                    var cities = DbContext.Cities.ToList();
                    cityList = cities;
                    return(cityList);
                }
            }
            catch (Exception e)
            {
                return(cityList);
            }
        }
Esempio n. 6
0
        public City ViewCity(int City_ID)
        {
            City city = new City();

            try
            {
                using (MSTDCEntities DbContext = new MSTDCEntities())
                {
                    var city1 = DbContext.Cities.Where(x => x.City_ID == City_ID).First();
                    city = city1;
                    return(city);
                }
            }
            catch (Exception e)
            {
                return(city);
            }
        }
Esempio n. 7
0
        public bool DeleteCity(int city_id)
        {
            try
            {
                using (MSTDCEntities dbContext = new MSTDCEntities())
                {
                    var s = dbContext.Cities.First(x => x.City_ID == city_id);
                    dbContext.Cities.Remove(s);
                    dbContext.SaveChanges();
                }

                return(true);
            }
            catch (Exception ex)
            {
                return(false);
            }
        }
Esempio n. 8
0
        public List <Hotel> ViewAllHotels()
        {
            List <Hotel> hotelList = new List <Hotel>();

            try
            {
                using (MSTDCEntities DbContext = new MSTDCEntities())
                {
                    var hotel1 = DbContext.Hotels.ToList();
                    hotelList = hotel1;
                    return(hotelList);
                }
            }
            catch (Exception e)
            {
                return(hotelList);
            }
        }
Esempio n. 9
0
        public Hotel ViewHotel(int hotel_ID)
        {
            Hotel hotel = new Hotel();

            try
            {
                using (MSTDCEntities DbContext = new MSTDCEntities())
                {
                    var hotel1 = DbContext.Hotels.Where(x => x.Hotel_ID == hotel_ID).First();
                    hotel = hotel1;
                    return(hotel);
                }
            }
            catch (Exception e)
            {
                return(hotel);
            }
        }
Esempio n. 10
0
        public bool DeleteHotel(int hotel_ID)
        {
            try
            {
                using (MSTDCEntities dbContext = new MSTDCEntities())
                {
                    var hotel = dbContext.Hotels.First(x => x.Hotel_ID == hotel_ID);
                    dbContext.Hotels.Remove(hotel);
                    dbContext.SaveChanges();
                }

                return(true);
            }
            catch (Exception ex)
            {
                return(false);
            }
        }
Esempio n. 11
0
        public List <Place> ViewAllPlaces()
        {
            List <Place> placeList = new List <Place>();

            try
            {
                using (MSTDCEntities DbContext = new MSTDCEntities())
                {
                    var places = DbContext.Places.ToList();
                    placeList = places;
                    return(placeList);
                }
            }
            catch (Exception e)
            {
                return(placeList);
            }
        }
Esempio n. 12
0
        public Place ViewPlace(int Place_ID)
        {
            Place place = new Place();

            try
            {
                using (MSTDCEntities DbContext = new MSTDCEntities())
                {
                    var place1 = DbContext.Places.Where(x => x.Place_ID == Place_ID).First();
                    place = place1;
                    return(place);
                }
            }
            catch (Exception e)
            {
                return(place);
            }
        }
Esempio n. 13
0
        public bool DeletePlace(int Place_ID)
        {
            try
            {
                using (MSTDCEntities dbContext = new MSTDCEntities())
                {
                    var place = dbContext.Places.First(x => x.Place_ID == Place_ID);
                    dbContext.Places.Remove(place);
                    dbContext.SaveChanges();
                }

                return(true);
            }
            catch (Exception ex)
            {
                return(false);
            }
        }
Esempio n. 14
0
        public bool UpdateCity(City city)
        {
            try
            {
                using (MSTDCEntities dbContext = new MSTDCEntities())
                {
                    var city1 = dbContext.Cities.Find(city.City_ID);
                    city1.City_ID   = city.City_ID;
                    city1.City_Name = city.City_Name;
                    city1.District  = city.District;
                    dbContext.SaveChanges();

                    return(true);
                }
            }
            catch (Exception e)
            {
                return(false);
            }
        }
Esempio n. 15
0
        public bool UpdatePlace(Place place)
        {
            try
            {
                using (MSTDCEntities dbContext = new MSTDCEntities())
                {
                    var place1 = dbContext.Places.Find(place.Place_ID);
                    place1.Place_ID    = place.Place_ID;
                    place1.Place_Name  = place.Place_Name;
                    place1.Description = place.Description;
                    place1.City_ID     = place.City_ID;
                    dbContext.SaveChanges();

                    return(true);
                }
            }
            catch (Exception e)
            {
                return(false);
            }
        }