Exemplo n.º 1
0
	/// <summary>
	/// Create a button for each route in a attraction
	/// </summary>
	/// <param name="attraction">The attration that contain the routes</param>
	public void CreateRouteMenu(Attraction attraction)
	{
		if (parentRoute.childCount > 0)
		{
			RemoveAllChild(parentRoute);
		}

		Dictionary<string, Element> elements = attraction.elements;
		IEnumerable<Element> route = from elmt in elements.Values where elmt.type == "Parcours" select elmt;

		int i = 0;
		foreach (Element ele in route)
		{
			if (!ToolBox.Instance.settings.savedRoute || (ToolBox.Instance.settings.savedRoute && Load.IsRouteSaved(ele.id, attraction.Id)))
			{
				Button button = (Button)Instantiate(buttonPrefab);
				button.GetComponent<MenuButton>().id = ele.id;
				button.GetComponentInChildren<Text>().text = ele.title;
				button.transform.SetParent(parentRoute, false);
				i++;
			}
		}
#if LOG
		Debug.Log("Number of route: " + i.ToString());
#endif
	}
        public AttractionBook(Attraction attr)
        {
            InitializeComponent();
            this.attraction = attr;

            foreach (Ticket tick in attraction.Ticket)
                listBox1.Items.Add(tick.Name);
        }
Exemplo n.º 3
0
    void Awake()
    {
        _children = new List<Element>();
        _transform = transform;
        _repulsion = GetComponent<Repulsion>();
        _attraction = GetComponent<Attraction>();
        _elementsContainer = GameObject.FindGameObjectWithTag("GameManager").GetComponent<ElementsContainer>();

        _repulsion.Repulsing += Repulsing;
    }
Exemplo n.º 4
0
	public static Dictionary<string, Attraction> Parse(string json)
	{
		Dictionary<string, Attraction> attractions = new Dictionary<string, Attraction>();

		List<System.Object> listAttractions = Json.Deserialize(json) as List<System.Object>;
		foreach (System.Object objAttraction in listAttractions)
		{
			Dictionary<string, System.Object> dicAttraction = objAttraction as Dictionary<string, System.Object>;
			Attraction attraction = new Attraction();

			attraction.Id = dicAttraction["id"] as string;
			attraction.name = dicAttraction["nom"] as string;
			attraction.description = dicAttraction["description"] as string;
			attraction.addDate = dicAttraction["dateAjoute"] as string;
			attraction.lastModificationDate = dicAttraction["dateModifie"] as string;
			attraction.elements = new Dictionary<string, Element>();

			List<System.Object> listElements = dicAttraction["elements"] as List<System.Object>;
			foreach (System.Object objElement in listElements)
			{
				Dictionary<string, System.Object> dicElement = objElement as Dictionary<string, System.Object>;
				Element element = new Element();

				element.id = dicElement["id"] as string;
				element.title = dicElement["titre"] as string;
				element.description = dicElement["description"] as string;
				element.type = dicElement["type"] as string;
				element.latitude = dicElement["latitude"] as string;
				element.longitude = dicElement["longitude"] as string;
				element.elevation = dicElement["elevation"] as string;
				element.orientation = dicElement["orientation"] as string;
				element.transparency = dicElement["transparence"] as string;
				element.ratio = dicElement["ratio"] as string;
				element.fileName = dicElement["nomFichier"] as string;
				element.addDate = dicElement["eDateAjoute"] as string;
				element.lastModificationDate = dicElement["eDateModifie"] as string;

				attraction.elements.Add(element.id, element);
			}

			attractions.Add(attraction.Id, attraction);
		}

		return attractions;
	}
 private async void BtnDelete_Click(object sender, RoutedEventArgs e)
 {
     popup.IsOpen = false;
     if (LvAll.SelectedItem != null)
     {
         try
         {
             Attraction a = LvAll.SelectedItem as Attraction;
             await Task.Run(() => AdminInterface.RemoveAsync(a));
         }
         catch (Exception ex)
         {
             popup        = ConfigurePopup.Configure(popup, ex.Message, BtnDelete, PlacementMode.Bottom);
             popup.IsOpen = true;
         }
     }
     else
     {
         popup        = ConfigurePopup.Configure(popup, "Select item first!", LvAll, PlacementMode.Right);
         popup.IsOpen = true;
     }
 }
Exemplo n.º 6
0
        public ActionResult AddAttraction(Attraction att)
        {
            if (ModelState.IsValid)
            {
                List <Attraction> attractionList = null;
                using (StreamReader r = new StreamReader(Server.MapPath("~/data.json")))
                {
                    string json = r.ReadToEnd();
                    attractionList = JsonConvert.DeserializeObject <List <Attraction> >(json);
                }

                attractionList.Add(att);

                using (StreamWriter w = new StreamWriter(Server.MapPath("~/data.json")))
                {
                    var jsonOut = JsonConvert.SerializeObject(attractionList);
                    w.Write(jsonOut);
                }
                return(RedirectToAction("Attractions", "Home"));
            }
            return(View(att));
        }
        //[Route("update")]
        public IActionResult Update(Attraction attraction)
        {
            var oldAttraction = _context.Attractions.FirstOrDefault(x => x.Id == attraction.Id);

            if (oldAttraction == null)
            {
                return(NotFound());
            }

            _context.Entry(oldAttraction).CurrentValues.SetValues(attraction);

            try
            {
                _context.SaveChanges();
                return(Ok());
            }
            catch (DBConcurrencyException e)
            {
                Console.WriteLine(e);
                throw;
            }
        }
Exemplo n.º 8
0
        public NavigationPage()
        {
            InitializeComponent();
            gc = GameController.getInstance();
            leftArrow.Source           = ServerConection.URL_MEDIA + "leftArrow.jpg";
            rightArrow.Source          = ServerConection.URL_MEDIA + "rightArrow.jpg";
            temperature.Source         = ServerConection.URL_MEDIA + "thermometer.jpg";
            v.Source                   = ServerConection.URL_MEDIA + "v.png";
            odometer.Maximum           = 1;
            odometer.Minimum           = 0;
            odometer.MinimumTrackColor = Color.FromHex("#0066ff");
            odometer.MaximumTrackColor = Color.FromHex("#0066ff");
            odometer.Value             = 0;
            odometer.WidthRequest      = temperature.HeightRequest;
            //hintBtn.Padding = 0;
            //hintBtn.WidthRequest = hintFrame.Width;
            //hintBtn.Margin = new Thickness(
            //    leftArrow.Width + hintFrame.Margin.Left + hintFrame.Padding.Left - 5,
            //    10,
            //    hintFrame.Margin.Right + hintFrame.Padding.Right,
            //    10);
            nextAttraction = gc.currentTrip.GetCurrentAttraction();
            myMap          = MapPage.GetInstance();
            mapBtn.Source  = ServerConection.URL_MEDIA + "map.png";
            //mapBtn = myMap.map;
            AttachHint(0);

            lc            = LocationController.GetInstance();
            attractionLoc = new trumpeldor.SheredClasses.Point(nextAttraction.x, nextAttraction.y);
            if (isFirst)
            {
                isFirst = false;
                //Task.Run(() => TimerCheck()).ConfigureAwait(false);
                //TimerCheck();
            }
            myMap.AddCurrlocationToMap(gc.GetUserLocation());
            TimerCheck();
        }
        public bool AddAttraction(Attraction attraction)
        {
            OracleCommand cmd = new OracleCommand("insert_procedure.insert_attraction",
                                                  connection)
            {
                CommandType = CommandType.StoredProcedure
            };

            cmd.Parameters.Add("v_name", OracleDbType.Varchar2).Value            = attraction.Name;
            cmd.Parameters.Add("v_desc", OracleDbType.Varchar2).Value            = attraction.Description;
            cmd.Parameters.Add("v_open_time", OracleDbType.Varchar2).Value       = DateTime.Parse(attraction.OpenTime.ToString());
            cmd.Parameters.Add("v_close_time", OracleDbType.Varchar2).Value      = DateTime.Parse(attraction.CloseTime.ToString());
            cmd.Parameters.Add("v_phone_number", OracleDbType.Varchar2).Value    = attraction.PhoneNumber;
            cmd.Parameters.Add("v_image", OracleDbType.Varchar2).Value           = attraction.ImagePath;
            cmd.Parameters.Add("v_attraction_type_id", OracleDbType.Int32).Value = attraction.AttractionType.Id;
            cmd.Parameters.Add("v_location_id", OracleDbType.Int32).Value        = AddLocation(attraction.Location);
            cmd.Parameters.Add("v_user_id", OracleDbType.Int32).Value            = attraction.User.Id;


            try
            {
                if (cmd.Connection.State != ConnectionState.Open)
                {
                    cmd.Connection.Open();
                }
                cmd.ExecuteNonQuery();
                return(true);
            }
            catch (Exception e)
            {
                System.Diagnostics.Debug.WriteLine(e.ToString());
                return(false);
            }
            finally
            {
                DataBaseConnection.GetDbInstance().CloseDBConnection();
            }
        }
Exemplo n.º 10
0
        public List <Attraction> SelectByType(string filterType) //get same type from attraction db and put into list
        {
            string        DBConnect = ConfigurationManager.ConnectionStrings["ConnStr"].ConnectionString;
            SqlConnection myConn    = new SqlConnection(DBConnect);

            string         sqlStmt = "Select * from Attraction where attractionType = @paraType";
            SqlDataAdapter da      = new SqlDataAdapter(sqlStmt, myConn);

            da.SelectCommand.Parameters.AddWithValue("@paraType", filterType);

            DataSet ds = new DataSet();

            da.Fill(ds);

            List <Attraction> empList = new List <Attraction>();
            int rec_cnt = ds.Tables[0].Rows.Count;

            for (int i = 0; i < rec_cnt; i++)
            {
                DataRow row         = ds.Tables[0].Rows[i];
                int     id          = int.Parse(row["attractionId"].ToString());
                string  name        = row["attractionName"].ToString();
                string  image       = row["attractionImage"].ToString();
                string  price       = row["attractionPrice"].ToString();
                string  date        = row["DateTime"].ToString();
                string  desc        = row["attractionDesc"].ToString();
                string  loc         = row["attractionLocation"].ToString();
                decimal lat         = decimal.Parse(row["attractionLatitude"].ToString());
                decimal lon         = decimal.Parse(row["attractionLongitude"].ToString());
                string  interest    = row["attractionInterest"].ToString();
                string  type        = row["attractionType"].ToString();
                string  transaction = row["attractionTransaction"].ToString();

                Attraction obj = new Attraction(id, name, image, price, date, desc, loc, lat, lon, interest, type, transaction);
                empList.Add(obj);
            }
            return(empList);
        }
Exemplo n.º 11
0
        public Tuple <bool, List <Attraction> > getAttractionsByCity(City city, string begin)
        {
            bool result = true;
            List <Attraction> attractions = new List <Attraction>();
            string            command     = "SELECT a.attraction_code, a.name, a.city_id, a.type " +
                                            "FROM city c join attraction a ON c.city_id = a.city_id " +
                                            "WHERE c.name LIKE '" + begin + "%'";

            if (city != null)
            {
                string c = "'" + city.Name + "'";
                command += " AND c.name=" + c;
            }

            command += ";";
            lock (DbConnection.Locker)
            {
                MySqlDataReader dr = DbConnection.ExecuteQuery(command);
                if (dr != null)
                {
                    while (dr.Read())
                    {
                        string     id      = dr.GetString("attraction_code");
                        string     name    = dr.GetString("name");
                        string     city_id = dr.GetString("city_id");
                        string     type    = dr.GetString("type");
                        Attraction a       = new Attraction(id, name, city_id, type);
                        attractions.Add(a);
                    }
                    dr.Close();
                }
                else
                {
                    result = false;
                }
            }
            return(new Tuple <bool, List <Attraction> >(result, attractions));
        }
Exemplo n.º 12
0
        public ActionResult Attractions(int count)
        {
            Random random = new Random();

            for (int i = 0; i < count; ++i)
            {
                int        lat        = random.Next(10) > 5 ? 1 : -1;
                int        lon        = random.Next(10) > 5 ? 1 : -1;
                Attraction attraction = new Attraction();
                attraction.Address               = new Address();
                attraction.Address.City          = db.Place.OrderBy(x => x.ID).Skip(random.Next(db.Place.Count() - 1)).FirstOrDefault().Name;
                attraction.AttractionType        = db.AttractionType.OrderBy(x => x.ID).Skip(random.Next(db.AttractionType.Count() - 1)).FirstOrDefault();
                attraction.Coordinates           = new Coordinates();
                attraction.Coordinates.Latitude  = random.NextDouble() * 90 * lat;
                attraction.Coordinates.Longitude = random.NextDouble() * 180 * lon;
                attraction.Country               = db.Country.OrderBy(x => x.ID).Skip(random.Next(db.Country.Count() - 1)).FirstOrDefault();
                attraction.Description           = generateRandomText(random.Next(3, 10));
                attraction.Name = "Attraction " + i.ToString();
                db.Attraction.Add(attraction);
                db.SaveChanges();
            }
            return(RedirectToAction("Index", "Attraction"));
        }
Exemplo n.º 13
0
        public IEnumerator UpgradeAttractionWithMoney()
        {
            List <Vector2Int> positionList =
                wcObject.GetPositionList(new Vector2Int(0, 0), BuildingTypeSO.Direction.Down);

            gameManager.Money = 9999;
            Building wc = Building.SpawnBuilding(Vector3.zero, new Vector2Int(0, 0), BuildingTypeSO.Direction.Down, wcObject, positionList);

            yield return(new WaitForSeconds(0.1f));

            Attraction help  = (Attraction)wc;
            GameObject empty = new GameObject();

            help.brokeVisual = empty.transform;
            help.BreakBuilding();
            yield return(new WaitForSeconds(0.1f));

            bool helpBool = gameManager.UpgradeBuilding((Attraction)(wc));

            yield return(new WaitForSeconds(0.1f));

            Assert.IsFalse(false);
        }
Exemplo n.º 14
0
        public async Task <bool> AddAttractionToCity(int attractionId, int cityId)
        {
            City city = GetById(cityId).Result;

            if (CheckIfExists(city))
            {
                List <Attraction> attractions = city.attractions.ToList();
                Attraction        attraction  = await _context.Attractions.FirstOrDefaultAsync(attraction => attraction.id == attractionId);

                if (attraction == null)
                {
                    return(false);
                }

                attractions.Add(attraction);
                city.attractions = attractions;
                await Update(city);

                return(true);
            }

            return(false);
        }
Exemplo n.º 15
0
        public IEnumerator RepairAttractionWithMoneyButNoAvaliableMechanics()
        {
            test = false;
            List <Vector2Int> positionList =
                wcObject.GetPositionList(new Vector2Int(0, 0), BuildingTypeSO.Direction.Down);

            gameManager.Money = 99999;
            Building wc = Building.SpawnBuilding(Vector3.zero, new Vector2Int(0, 0), BuildingTypeSO.Direction.Down, wcObject, positionList);

            yield return(new WaitForSeconds(0.1f));

            Attraction help  = (Attraction)wc;
            GameObject empty = new GameObject();

            help.brokeVisual = empty.transform;
            help.BreakBuilding();
            yield return(new WaitForSeconds(0.1f));

            gameManager.RepairAttraction((Attraction)(wc));
            yield return(new WaitForSeconds(0.1f));

            Assert.AreEqual(99999, gameManager.Money);
        }
Exemplo n.º 16
0
        public Attraction SelectById(string attId) //get the attraction info by Id
        {
            string        DBConnect = ConfigurationManager.ConnectionStrings["ConnStr"].ConnectionString;
            SqlConnection myConn    = new SqlConnection(DBConnect);

            string         sqlstmt = "Select * from Attraction where attractionId = @paraId";
            SqlDataAdapter da      = new SqlDataAdapter(sqlstmt, myConn);

            da.SelectCommand.Parameters.AddWithValue("@paraId", attId);

            DataSet ds = new DataSet();

            da.Fill(ds);
            int rec_cnt = ds.Tables[0].Rows.Count;

            Attraction td = null;

            if (rec_cnt > 0)
            {
                DataRow row         = ds.Tables[0].Rows[0];
                int     id          = int.Parse(row["attractionId"].ToString());
                string  name        = row["attractionName"].ToString();
                string  image       = row["attractionImage"].ToString();
                string  price       = row["attractionPrice"].ToString();
                string  date        = row["DateTime"].ToString();
                string  desc        = row["attractionDesc"].ToString();
                string  loc         = row["attractionLocation"].ToString();
                decimal lat         = decimal.Parse(row["attractionLatitude"].ToString());
                decimal lon         = decimal.Parse(row["attractionLongitude"].ToString());
                string  interest    = row["attractionInterest"].ToString();
                string  type        = row["attractionType"].ToString();
                string  transaction = row["attractionTransaction"].ToString();

                td = new Attraction(id, name, image, price, date, desc, loc, lat, lon, interest, type, transaction);
            }
            return(td);
        }
Exemplo n.º 17
0
        public ActionResult Create(Attraction attraction)
        {
            attraction.AttractionType = db.AttractionType.Find(attraction.AttractionType.ID);
            attraction.Country        = db.Country.Find(attraction.Country.ID);
            attraction.AvgRating      = 0.0;

            //upload photos
            try
            {
                int i = 0;
                foreach (string upload in Request.Files)
                {
                    if (Request.Files[i].ContentLength == 0)
                    {
                        continue;
                    }

                    string          path = AppDomain.CurrentDomain.BaseDirectory + "Content/AttractionImages/";
                    string          ext  = Request.Files[i].FileName.Substring(Request.Files[i].FileName.LastIndexOf('.'));
                    AttractionImage ai   = new AttractionImage {
                        AttractionID = attraction.ID, FileName = generateRandomString(32) + ext
                    };
                    attraction.Images.Add(ai);
                    Request.Files[i].SaveAs(Path.Combine(path, ai.FileName));
                    i++;
                }
            }
            catch (NullReferenceException)
            {
                //no photo
            }
            //end of upload user photo

            db.Attraction.Add(attraction);
            db.SaveChanges();
            return(RedirectToAction("Details", new { id = attraction.ID }));
        }
        public ITrip CreateTrip()
        {
            ITrip trip = travelAgency.CreateTrip();

            trip.Country = "France";
            IAttraction attraction;

            for (int i = 0; i < trip.DaysCount; i++)
            {
                for (int j = 0; j < 3; j++)
                {
                    do
                    {
                        if (tripAdvisorIterator.HasNext())
                        {
                            attraction        = tripAdvisorIterator.GetCurrent();
                            attraction.Rating = tripAdvisorDescrambler.Handle(attraction.Rating);
                            attraction.Price  = tripAdvisorDescrambler.Handle(attraction.Price);
                        }
                        else
                        {
                            tripAdvisorIterator.Reset();
                            if (!tripAdvisorIterator.HasNext())
                            {
                                attraction = new Attraction();
                                break;
                            }
                            attraction        = tripAdvisorIterator.GetCurrent();
                            attraction.Rating = tripAdvisorDescrambler.Handle(attraction.Rating);
                            attraction.Price  = tripAdvisorDescrambler.Handle(attraction.Price);
                        }
                    } while (attraction.Country != "France");
                    trip.Attractions[i].Add(attraction);
                }
            }
            return(trip);
        }
Exemplo n.º 19
0
        public SlidingPuzzlePage(SlidingPuzzle sp, Attraction attraction)
        {
            InitializeComponent();
            this.gc          = GameController.getInstance();
            subtitles.Source = ServerConection.URL_MEDIA + "subtitles.jpg";
            info.Source      = ServerConection.URL_MEDIA + "info.jpg";
            playVideo.Source = ServerConection.URL_MEDIA + "playVideo.jpg";
            how.Source       = ServerConection.URL_MEDIA + "how.png";
            this.sp          = sp;
            taps             = new List <Tuple <int, int> >();
            tiles            = new SlidingPuzzleTile[sp.width, sp.height];
            emptyRow         = sp.width - 1;
            emptyCol         = sp.height - 1;
            this.attraction  = attraction;

            for (int row = 0; row < sp.width; row++)
            {
                for (int col = 0; col < sp.height; col++)
                {
                    if (row == emptyRow && col == emptyCol)
                    {
                        break;
                    }
                    SlidingPuzzleTile tile = new SlidingPuzzleTile(row, col, sp.piecesURLS[row * sp.width + col]);

                    TapGestureRecognizer tapGestureRecognizer = new TapGestureRecognizer();
                    tapGestureRecognizer.Tapped += OnTileTapped;
                    tile.TileView.GestureRecognizers.Add(tapGestureRecognizer);

                    tiles[row, col] = tile;
                    absoluteLayout.Children.Add(tile.TileView);
                }
            }

            shuffle();
        }
    public void DisplayDetails(Attraction building)
    {
        buyMenu.SetActive(false);
        BuySelect.instance.SetCheck();
        selectedBuilding = building;
        display.gameObject.SetActive(true);
        nameText.text     = building.Name;
        level.text        = "Level: " + building.Level;
        capacity.text     = "Capacity: " + building.CurrentVisitorCount + "/" + building.TotalCapacity;
        upkeep.text       = "Upkeep: -" + Math.Round(building.DailyUpkeep, 0) + "$";
        income.text       = "Income: " + Math.Round(building.CurrentDailyIncome, 0) + "$";
        netIncome.text    = "Net Income: " + Math.Round(building.CurrentDailyIncome - building.DailyUpkeep, 0) + "$";
        upgradePrice.text = Math.Round(building.UpgradePrice, 0) + "$";
        repairPrice.text  = Math.Round((building.Value * 0.1f), 0) + "$";
        if (previewModelObject != null)
        {
            Destroy(previewModelObject.gameObject);
        }

        previewModelObject = Instantiate(building.Type.uiPrefab, previewModel);

        if (!selectedBuilding.Broke)
        {
            repairButton.interactable = false;
        }
        else if (selectedBuilding.beingRepaired || GameManager.instance.availableMechanics <= 0)
        {
            repairButton.interactable = false;
        }
        else
        {
            repairButton.interactable = true;
        }

        inspectorOpen = true;
    }
Exemplo n.º 21
0
    static void Main(string[] args)
    {
        int numberOfAttractions = int.Parse(Console.ReadLine());
        List<Attraction> attractions = new List<Attraction>();
        for (int attractionNumber = 0; attractionNumber < numberOfAttractions; attractionNumber++)
        {
            string[] attractionInput = Console.ReadLine().Split(' ');
            Attraction attraction = new Attraction();
            attraction.id = int.Parse(attractionInput[0]);
            attraction.position.latitude = double.Parse(attractionInput[1], CultureInfo.InvariantCulture);
            attraction.position.longitude = double.Parse(attractionInput[2], CultureInfo.InvariantCulture);
            attractions.Add(attraction);
        }

        int testNumber = int.Parse(Console.ReadLine());
        while (testNumber-- > 0)
        {
            Point travelerPosition = new Point();
            string[] restrictions = Console.ReadLine().Split(' ');
            travelerPosition.latitude = double.Parse(restrictions[0], CultureInfo.InvariantCulture);
            travelerPosition.longitude = double.Parse(restrictions[1], CultureInfo.InvariantCulture);
            double speed = GetSpeed(restrictions[2]);
            double minutes = double.Parse(restrictions[3]);
            List<Attraction> goodAttractions = new List<Attraction>();
            for (int i = 0; i < attractions.Count; i++)
            {
                Attraction attr = attractions[i];
                attr.distance = GetDistance(travelerPosition, attr.position);
                if (attr.distance / speed * 60.0 <= minutes)
                {
                    goodAttractions.Add(attr);
                }
            }

            for (int i = 0; i < goodAttractions.Count - 1; i++)
            {
                for (int j = i + 1; j < goodAttractions.Count; j++)
                {

                    if (goodAttractions[i].distance > goodAttractions[j].distance)
                    {
                        Attraction tmp = goodAttractions[i];
                        goodAttractions[i] = goodAttractions[j];
                        goodAttractions[j] = tmp;
                    }

                }
            }
            for (int i = 0; i < goodAttractions.Count - 1; i++)
            {
                for (int j = i + 1; j < goodAttractions.Count; j++)
                {
                    if (goodAttractions[i].distance == goodAttractions[j].distance)
                    {
                        if (goodAttractions[i].id > goodAttractions[j].id)
                        {
                            Attraction tmp = goodAttractions[i];
                            goodAttractions[i] = goodAttractions[j];
                            goodAttractions[j] = tmp;
                        }
                    }
                }
            }

            foreach(Attraction attr in goodAttractions)
            {
                Console.Write(attr.id+" ");
            }
            Console.WriteLine();
        }
    }
    protected void btnSearch_Click(object sender, EventArgs e)
    {
        //Showing result when user search by bookings by booking id
        lblCustomer.Visible = false;
        dlCustomer.Visible  = false;
        lblTitle.Text       = "Search Results";
        gvUpcoming.Visible  = false;
        gvHistory.Visible   = false;
        //Getting current signed in user
        Attraction attraction = (Attraction)Session["userAttraction"];
        //Getting booked rooms from session and display them
        List <ItemBooking> itemList  = (List <ItemBooking>)Session["Upcoming"];
        List <ItemBooking> itemList2 = (List <ItemBooking>)Session["History"];
        List <ItemBooking> upcoming  = new List <ItemBooking>();
        List <ItemBooking> history   = new List <ItemBooking>();

        //Searching in upcoming bookings
        if (itemList != null)
        {
            foreach (ItemBooking it in itemList)
            {
                if (tbxBookingID.Text == it.BookingID.BookingID.ToString())
                {
                    //showing results for upcoming bookings
                    ItemBooking item = it;
                    upcoming.Add(item);
                    gvUpcoming.DataSource = upcoming;
                    gvUpcoming.DataBind();
                    gvUpcoming.Visible  = true;
                    lblNoResult.Visible = false;
                }
                else
                {
                    lblNoResult.Text = "Sorry! No booking is found!";
                }
            }
        }
        //Searching in past booking
        if (itemList2 != null)
        {
            foreach (ItemBooking it in itemList2)
            {
                if (tbxBookingID.Text == it.BookingID.BookingID.ToString())
                {
                    //showing results for past bookings
                    ItemBooking item = it;
                    history.Add(item);
                    gvHistory.DataSource = history;
                    gvHistory.DataBind();
                    lblNoResult.Text  = "";
                    gvHistory.Visible = true;
                }
                else
                {
                    lblNoResult.Text = "Sorry! No booking is found!";
                }
            }
        }
        //if booking is not found
        if (itemList == null && itemList2 == null)
        {
            lblNoResult.Text = "Sorry! No booking is found!";
        }
        //if user click search without providing booking id, it will show upcoming bookings
        if (tbxBookingID.Text == "")
        {
            lblNoResult.Text = "";
            lblTitle.Text    = "Upcoming Booking";
            List <ItemBooking> itemList3 = (List <ItemBooking>)Session["Upcoming"];
            //Showing upcoming bookings
            gvUpcoming.DataSource = itemList3;
            gvUpcoming.DataBind();
            gvHistory.Visible  = false;
            gvUpcoming.Visible = true;
        }
    }
Exemplo n.º 23
0
        void SetFeedingtimeBlocks()
        {
            List <Animal> TempAnimalList = new List <Animal>();

            Animal animal;

            for (int i = AttractionDataBase.Attractions.Count - 1; i > 0; i--)
            {
                Attraction attraction = AttractionDataBase.Attractions[i];
                if (attraction is Animal && (attraction as Animal).HasFeedingTime && (attraction as Animal).IsInSeason)
                {
                    animal = (attraction as Animal);
                    TempAnimalList.Add(animal);
                }
            }

            TempAnimalList = TempAnimalList.OrderBy(x => x.NextFeeding).ToList();

            LinearLayout Scheme = FindViewById <LinearLayout>(Resource.Id.FeedingTimeSchemeLayout);
            LinearLayout Text   = FindViewById <LinearLayout>(Resource.Id.FeedingTimeSchemeText);
            LinearLayout Root   = FindViewById <LinearLayout>(Resource.Id.FeedingTimeSchemeRoot);
            Random       rng    = new Random();
            int          index  = 0;

            foreach (Animal a in TempAnimalList)
            {
                View animalText = LayoutInflater.Inflate(Resource.Layout.AnimalFeedingText, Text, false);

                Color[] colours = new Color[] { Color.Red, Color.Green, Color.Blue, Color.Yellow, Color.Red, Color.Green, Color.Blue, Color.Yellow, Color.Red, Color.Green, Color.Blue, Color.Yellow, Color.Red, Color.Green, Color.Blue, Color.Yellow };

                LinearLayout horizontalAnimalLayout = (LinearLayout)LayoutInflater.Inflate(Resource.Layout.LinearLayout, Scheme, false);
                LinearLayout.LayoutParams LL        = new LinearLayout.LayoutParams(24 * 60 * 5, feedingtimeLineHeight);
                horizontalAnimalLayout.Orientation = Orientation.Horizontal;
                //  horizontalAnimalLayout.SetBackgroundColor(colours[index]);

                horizontalAnimalLayout.LayoutParameters = LL;
                Scheme.AddView(horizontalAnimalLayout);


                LinearLayout.LayoutParams animalTextLL = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.FillParent, feedingtimeLineHeight);
                animalText.LayoutParameters = animalTextLL;
                if ((animalText as ViewGroup).GetChildAt(0) is ImageView)
                {
                    System.IO.Stream ims = Assets.Open("img/AnimalHeaders/" + (a as Animal).ImageName + "Header.png");
                    // load image as Drawable
                    Bitmap bitmap = BitmapFactory.DecodeStream(ims);
                    ims.Close();

                    ((animalText as ViewGroup).GetChildAt(0) as ImageView).SetImageBitmap(bitmap);
                    ((animalText as ViewGroup).GetChildAt(0) as ImageView).Click += delegate {
                        selectedAnimal = a;
                        PopupMenu menu = new PopupMenu(this, ((animalText as ViewGroup).GetChildAt(0) as ImageView));
                        menu.MenuInflater.Inflate(Resource.Layout.FeedingAlarmMenu, menu.Menu);
                        menu.Show();

                        IMenuItem item = menu.Menu.FindItem(Resource.Id.MenuReminderButton);

                        menu.MenuItemClick += delegate {
                            Console.WriteLine(selectedAnimal.Name + AttractionDataBase.animalsToWatch.Contains(selectedAnimal));
                            foreach (Animal an in AttractionDataBase.animalsToWatch)
                            {
                                Console.WriteLine(an.Name);
                            }
                            if (AttractionDataBase.animalsToWatch.Contains(selectedAnimal))
                            {
                                AttractionDataBase.animalsToWatch.Remove(selectedAnimal);
                            }
                            else
                            {
                                AttractionDataBase.animalsToWatch.Add(selectedAnimal);
                                Console.WriteLine("ADDING");
                            }
                        };

                        if (AttractionDataBase.animalsToWatch.Contains(selectedAnimal))
                        {
                            item.SetTitle("Fjern påmindese?");
                        }
                        else
                        {
                            item.SetTitle("Sæt påmindelse?");
                        }
                        SpannableString spanString = new SpannableString(item.TitleFormatted);
                        int             end        = spanString.Length();
                        spanString.SetSpan(new RelativeSizeSpan(0.8f), 0, end, SpanTypes.ExclusiveExclusive);
                        item.SetTitle(spanString);
                    };
                }
                if ((animalText as ViewGroup).GetChildAt(1) is LinearLayout)
                {
                    ((animalText as ViewGroup).GetChildAt(1) as LinearLayout).LayoutParameters.Height = feedingtimeLineHeight;
                }
                Text.AddView(animalText);


                LinearLayout.LayoutParams horizontalLine = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MatchParent, 2);
                View textLine = LayoutInflater.Inflate(Resource.Layout.line, Text, false);
                textLine = LayoutInflater.Inflate(Resource.Layout.line, Text, false);
                textLine.LayoutParameters = horizontalLine;
                textLine.SetBackgroundColor(Color.ParseColor("#000000"));


                int feedingtimeCounter = 0;
                foreach (FeedingTime FT in a.FeedingTimes)
                {
                    //set the destination

                    View animalBlock = LayoutInflater.Inflate(Resource.Layout.AnimalFeedingBlock, (LinearLayout)Scheme.GetChildAt(index), false);

                    //Find the text and linearlayout children

                    LinearLayout.LayoutParams animalBlockParams = new LinearLayout.LayoutParams((animalBlock as LinearLayout).LayoutParameters.Width = FT.ShowLength * 5, feedingtimeLineHeight);

                    (animalBlock as LinearLayout).LayoutParameters = animalBlockParams;
                    //((animalBlock as ViewGroup).GetChildAt(i) as LinearLayout).Left = FT.TimeOfDay.Hour * 60 * 5 + FT.TimeOfDay.Second * 5;

                    int timeBeforeCurrentFeedingtime = 0;
                    for (int i = 0; i < feedingtimeCounter; i++)
                    {
                        timeBeforeCurrentFeedingtime += a.FeedingTimes[i].TimeOfDay.Hour * 60 * 5 + a.FeedingTimes[i].TimeOfDay.Minute * 5 + a.FeedingTimes[i].ShowLength * 5 + 25;
                    }

                    animalBlockParams.LeftMargin = (int)(FT.TimeOfDay.Hour * 60 + FT.TimeOfDay.Minute)
                                                   * 5 + 25 - timeBeforeCurrentFeedingtime;

                    (animalBlock as LinearLayout).SetBackgroundColor(Color.ParseColor("#e6e8ed"));
                    (animalBlock as LinearLayout).LayoutParameters.Height = feedingtimeLineHeight;

                    ((animalBlock as ViewGroup).GetChildAt(0) as TextView).Text = (FT.TimeOfDay.Hour.ToString("00") + ":" + FT.TimeOfDay.Minute.ToString("00"));

                    (Scheme.GetChildAt(index) as LinearLayout).AddView(animalBlock);
                    feedingtimeCounter++;
                }

                View blockLine = LayoutInflater.Inflate(Resource.Layout.line, Scheme, false);
                horizontalLine             = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MatchParent, 2);
                blockLine.LayoutParameters = horizontalLine;
                blockLine.SetBackgroundColor(Color.ParseColor("#000000"));
                Scheme.AddView(blockLine);

                index += 2;
                Text.AddView(textLine);
            }
        }
Exemplo n.º 24
0
    protected void btnLogin_Click(object sender, EventArgs e)
    {
        //get admin from database
        Admin d = AdminDB.getAdminbyID(tbxEmail.Text, tbxPassword.Text);

        if (d != null)                              //if admin is not null
        {
            if (d.AdminID == tbxEmail.Text)         //check the admin id from database, matched or not
            {
                if (d.Password == tbxPassword.Text) //check the admin password from database, matched or not
                {
                    //create a session for admin
                    Session["admin"] = d;
                    //redirect to AdminView page
                    Server.Transfer("AdminView.aspx");
                }
            }
        }
        else
        {
            lblOutput.Text = "sorry admin cannot login!"; //to show error message
        }

        if (ddlCustOrg.SelectedItem.Text == "Customer")                                  //user selected on customer
        {
            Customer c = CustomerDB.getCustomerByEmail(tbxEmail.Text, tbxPassword.Text); //get the customer details from database
            if (c != null)                                                               //if customer is not null
            {
                //customer email and password must matched from the databse
                if (c.CustEmail == tbxEmail.Text)
                {
                    if (c.Password == tbxPassword.Text)
                    {
                        //create session for user
                        Session["user"]      = c;
                        Session["emailUser"] = c.CustEmail;
                        //redirect to the default page
                        Server.Transfer("Default.aspx");
                    }
                    else
                    {
                        lblOutput.Text = "Incorrect password"; //show error message
                    }
                }
            }
            else
            {
                lblOutput.Text = "Incorrect email/password"; //show error message
            }
        }


        else if (ddlCustOrg.SelectedItem.Text == "Hotel Owner")                 //user selected on hotel owner
        {
            Hotel h = HotelDB.getHotelByEmail(tbxEmail.Text, tbxPassword.Text); //get the data from database
            //check the data is not null
            if (h != null)
            {
                //email and password must matched into the database
                if (h.OrgEmail == tbxEmail.Text)
                {
                    if (h.Password == tbxPassword.Text)
                    {
                        //create session for user
                        Session["userHotel"]  = h;
                        Session["hotelEmail"] = h.OrgEmail;
                        Session["hotelID"]    = h.HotelID;

                        //redirect to the default page
                        Server.Transfer("Default.aspx");
                    }
                    else
                    {
                        lblOutput.Text = "Incorrect password"; //show error message
                    }
                }
            }
            else
            {
                lblOutput.Text = "Incorrect email/password"; //show error message
            }
        }
        else if (ddlCustOrg.SelectedItem.Text == "Restaurant Owner") //user selected on the restaurant owner
        {
            //get the data from database
            Restaurant r = RestaurantDB.getRestaurantByEmail(tbxEmail.Text, tbxPassword.Text);
            //check the data is not null
            if (r != null)
            {
                //email and password must matched into database
                if (r.OrgEmail == tbxEmail.Text)
                {
                    if (r.Password == tbxPassword.Text)
                    {
                        //create session for user
                        Session["userRestaurant"]  = r;
                        Session["restaurantEmail"] = r.OrgEmail;
                        Session["restaurantID"]    = r.RestaurantID;

                        //redirect to the default page
                        Server.Transfer("Default.aspx");
                    }
                    else
                    {
                        lblOutput.Text = "Incorrect password"; //show error message
                    }
                }
            }
            else
            {
                lblOutput.Text = "Incorrect email/password"; //show error message
            }
        }
        else if (ddlCustOrg.SelectedItem.Text == "Attraction Owner") //user selected on the attraction owner
        {
            //get the data from database
            Attraction a = AttractionDB.getAttractionByEmail(tbxEmail.Text, tbxPassword.Text);
            //check the data if not null
            if (a != null)
            {
                //email and password must matched into our database
                if (a.OrgEmail == tbxEmail.Text)
                {
                    if (a.Password == tbxPassword.Text)
                    {
                        //create session for user
                        Session["userAttraction"]  = a;
                        Session["attractionEmail"] = a.OrgEmail;
                        Session["attractionID"]    = a.AttractionID;

                        //redirect to the default page
                        Server.Transfer("Default.aspx");
                    }
                    else
                    {
                        lblOutput.Text = "Incorrect password";  //show error message
                    }
                }
            }
            else
            {
                lblOutput.Text = "Incorrect email/password"; //show error message
            }
        }
    }
Exemplo n.º 25
0
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        //initialize the random number generator
        Random r = new Random();
        //set the new password from random number generator
        int newPw = r.Next(1, 100000);

        int  result = 0;                                //initialze the result
        bool found  = true;                             //initialize the boolean is true

        if (ddlCustOrg.SelectedItem.Text == "Customer") //when user choose to reset password for customer
        {
            //get the customer from database
            Customer c = CustomerDB.getACustomerByEmail(tbxEmail.Text);
            if (c != null)                                 //if the customer is not null
            {
                c.Password = newPw.ToString();             //set the new password
                result     = CustomerDB.updateCustomer(c); //update into customer database
            }
            else
            {
                found = false; //cannot find the customer from the database
            }
        }
        else if (ddlCustOrg.SelectedItem.Text == "Hotel Owner") //when user choose to reset password for hotel owner
        {
            Hotel h = HotelDB.getAHotelByEmail(tbxEmail.Text);  //get the hotel owner from database
            if (h != null)                                      //if the hotel is not null
            {
                h.Password = newPw.ToString();                  //set the new password
                result     = HotelDB.updateHotel(h);            //update into hotel database
            }
            else
            {
                found = false; //cannot find the hotel owner from the database
            }
        }
        else if (ddlCustOrg.SelectedItem.Text == "Attraction Owner")          //when user choose to reset password for attraction
        {
            Attraction a = AttractionDB.getAAttractionByEmail(tbxEmail.Text); //get the attraction owner from database
            if (a != null)                                                    //if the attraction is not null
            {
                //set the new password
                a.Password = newPw.ToString();
                //update into attraction database
                result = AttractionDB.updateAttraction(a);
            }
            else
            {
                found = false; //canoot find the attraction from the database
            }
        }
        else if (ddlCustOrg.SelectedItem.Text == "Restaurant Owner")           //when user choose to reset password for restaurant owner
        {
            Restaurant ra = RestaurantDB.getARestaurantByEmail(tbxEmail.Text); //get the restaurant owner from database
            if (ra != null)                                                    //if the restaurant is not null
            {
                //set the new password
                ra.Password = newPw.ToString();
                //update into restaurant database
                result = RestaurantDB.updateRestaurant(ra);
            }
            else
            {
                found = false; //cannot find the restaurant from the database
            }
        }
        if (found)          //if found
        {
            if (result > 0) //result cannot be zero
            {
                try         //use try and catch to send an email to the organization and customer
                {
                    SmtpClient client = new SmtpClient("smtp.gmail.com");
                    client.EnableSsl   = true;
                    client.Credentials = new NetworkCredential("*****@*****.**", "smart-travel1005");

                    MailMessage msg = new MailMessage("*****@*****.**", tbxEmail.Text);
                    msg.Subject = "New Password";
                    msg.Body    = "Your new password is: " + newPw.ToString() + "\r\n Please change your password again";
                    client.Send(msg); //send an email
                    lblOutput.Text = "New Password has been sent to your email";
                    return;
                }
                catch (Exception ex)
                {
                    lblOutput.Text = "Active internet connection needed!"; //show error message when user do not have internet connection
                    return;
                }
            }
            else
            {
                lblOutput.Text = "Fails to update the password"; //show error message when user cannot update the password
                return;
            }
        }
        lblOutput.Text = "Account with this email address does not exist. Sign up for the account"; //if the account is not exist with our website
    }
Exemplo n.º 26
0
    static void Main(string[] args)
    {
        int numberOfAttractions       = int.Parse(Console.ReadLine());
        List <Attraction> attractions = new List <Attraction>();

        for (int attractionNumber = 0; attractionNumber < numberOfAttractions; attractionNumber++)
        {
            string[]   attractionInput = Console.ReadLine().Split(' ');
            Attraction attraction      = new Attraction();
            attraction.id = int.Parse(attractionInput[0]);
            attraction.position.latitude  = double.Parse(attractionInput[1], CultureInfo.InvariantCulture);
            attraction.position.longitude = double.Parse(attractionInput[2], CultureInfo.InvariantCulture);
            attractions.Add(attraction);
        }

        int testNumber = int.Parse(Console.ReadLine());

        while (testNumber-- > 0)
        {
            Point    travelerPosition = new Point();
            string[] restrictions     = Console.ReadLine().Split(' ');
            travelerPosition.latitude  = double.Parse(restrictions[0], CultureInfo.InvariantCulture);
            travelerPosition.longitude = double.Parse(restrictions[1], CultureInfo.InvariantCulture);
            double            speed           = GetSpeed(restrictions[2]);
            double            minutes         = double.Parse(restrictions[3]);
            List <Attraction> goodAttractions = new List <Attraction>();
            for (int i = 0; i < attractions.Count; i++)
            {
                Attraction attr = attractions[i];
                attr.distance = GetDistance(travelerPosition, attr.position);
                if (attr.distance / speed * 60.0 <= minutes)
                {
                    goodAttractions.Add(attr);
                }
            }

            for (int i = 0; i < goodAttractions.Count - 1; i++)
            {
                for (int j = i + 1; j < goodAttractions.Count; j++)
                {
                    if (goodAttractions[i].distance > goodAttractions[j].distance)
                    {
                        Attraction tmp = goodAttractions[i];
                        goodAttractions[i] = goodAttractions[j];
                        goodAttractions[j] = tmp;
                    }
                }
            }
            for (int i = 0; i < goodAttractions.Count - 1; i++)
            {
                for (int j = i + 1; j < goodAttractions.Count; j++)
                {
                    if (goodAttractions[i].distance == goodAttractions[j].distance)
                    {
                        if (goodAttractions[i].id > goodAttractions[j].id)
                        {
                            Attraction tmp = goodAttractions[i];
                            goodAttractions[i] = goodAttractions[j];
                            goodAttractions[j] = tmp;
                        }
                    }
                }
            }

            foreach (Attraction attr in goodAttractions)
            {
                Console.Write(attr.id + " ");
            }
            Console.WriteLine();
        }
    }
Exemplo n.º 27
0
 public void DeleteAttraction(Attraction attraction)
 {
     _context.Attractions.Remove(attraction);
 }
Exemplo n.º 28
0
 public UpdateAttraction(Attraction attraction, IAdminInterface <Attraction> adminInterface)
 {
     InitializeComponent();
     Attraction     = attraction;
     AdminInterface = adminInterface;
 }
Exemplo n.º 29
0
 public void Repair(Attraction repairTarget)
 {
     targeted = repairTarget;
     GoToBuilding(targeted);
 }
Exemplo n.º 30
0
 public void UpdateAttractionForDestination(Attraction attraction)
 {
     // no code in this implementation
 }
Exemplo n.º 31
0
 private void DG1_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     objEmpToEdit = DG1.SelectedItem as Attraction;
 }
Exemplo n.º 32
0
 public void GetDestination()
 {
     attractionDest = AttractionManager.Instance.GetAttraction();
 }
Exemplo n.º 33
0
        public static void InitializeDb(ApplicationDbContext context, string adminId)
        {
            if (context.ParkInfo.Any())
            {
                return;
            }

            var pinfo = new ParkInfo[]
            {
                new ParkInfo
                {
                    Name         = "Houston Theme Park",
                    Country      = "USA",
                    State        = "TX",
                    City         = "Houston",
                    ZipCode      = "77042",
                    StreetNumber = "11223",
                    StreetName   = "Grant Rd"
                },
            };

            foreach (ParkInfo pi in pinfo)
            {
                context.ParkInfo.Add(pi);
            }
            context.SaveChanges();

            var phours = new ParkHour[]
            {
                new ParkHour
                {
                    ParkInfoId   = pinfo.Single(s => s.Name == "Houston Theme Park").Id,
                    FirstDayOpen = "Monday",
                    LastDayOpen  = "Saturday",
                    WorkingHours = "8:00am - 10:00pm"
                }
            };

            foreach (ParkHour ph in phours)
            {
                var parkHoursInDatabase = context.ParkHours.Where(s => s.ParkInfo.Id == ph.ParkInfoId).SingleOrDefault();
                if (parkHoursInDatabase == null)
                {
                    context.ParkHours.Add(ph);
                }
            }

            context.SaveChanges();


            var weather = new Weather[]
            {
                new Weather
                {
                    Date         = DateTime.Parse("2009-10-03"),
                    Rainout      = false,
                    Temperature  = 70.0m,
                    InchesOfRain = 0.0m
                }
            };

            foreach (Weather w in weather)
            {
                context.Weathers.Add(w);
            }
            context.SaveChanges();


            var dreports = new DailyReport[]
            {
                new DailyReport
                {
                    WeatherId = weather.Single(s => s.Date == DateTime.Parse("2009-10-03")).Id,
                    Date      = DateTime.Parse("2009-10-03")
                }
            };

            foreach (DailyReport dr in dreports)
            {
                context.DailyReports.Add(dr);
            }

            context.SaveChanges();


            var locations = new Location[]
            {
                new Location {
                    Name = "North"
                },
                new Location {
                    Name = "East"
                },
                new Location {
                    Name = "West"
                },
                new Location {
                    Name = "South"
                },
                new Location {
                    Name = "Center"
                }
            };

            foreach (Location l in locations)
            {
                context.Locaitons.Add(l);
            }
            context.SaveChanges();

            var atypes = new AttractionType[]
            {
                new AttractionType {
                    Name = "Roller Coaster"
                },
                new AttractionType {
                    Name = "Merry go Round"
                },
                new AttractionType {
                    Name = "Farris Wheel"
                },
                new AttractionType {
                    Name = "Haunted House"
                },
                new AttractionType {
                    Name = "Water Slide"
                }
            };

            foreach (AttractionType at in atypes)
            {
                context.AttractionTypes.Add(at);
            }
            context.SaveChanges();

            var attractions = new Attraction[]
            {
                new Attraction
                {
                    ParkInfoId       = pinfo.Single(s => s.Name == "Houston Theme Park").Id,
                    AttractionTypeId = atypes.Single(s => s.Name == "Haunted House").Id,
                    LocationId       = locations.Single(s => s.Name == "North").Id,
                    Name             = "Spooky House",
                    Description      = "Boo!",
                },
                new Attraction
                {
                    ParkInfoId       = pinfo.Single(s => s.Name == "Houston Theme Park").Id,
                    AttractionTypeId = atypes.Single(s => s.Name == "Roller Coaster").Id,
                    LocationId       = locations.Single(s => s.Name == "East").Id,
                    Name             = "Wild Ride",
                    Description      = "Wee!",
                },
                new Attraction
                {
                    ParkInfoId       = pinfo.Single(s => s.Name == "Houston Theme Park").Id,
                    AttractionTypeId = atypes.Single(s => s.Name == "Water Slide").Id,
                    LocationId       = locations.Single(s => s.Name == "West").Id,
                    Name             = "Water Snake",
                    Description      = "Hiss!",
                },
                new Attraction
                {
                    ParkInfoId       = pinfo.Single(s => s.Name == "Houston Theme Park").Id,
                    AttractionTypeId = atypes.Single(s => s.Name == "Farris Wheel").Id,
                    LocationId       = locations.Single(s => s.Name == "South").Id,
                    Name             = "Great View",
                    Description      = "Ooh!",
                },
                new Attraction
                {
                    ParkInfoId       = pinfo.Single(s => s.Name == "Houston Theme Park").Id,
                    AttractionTypeId = atypes.Single(s => s.Name == "Merry go Round").Id,
                    LocationId       = locations.Single(s => s.Name == "Center").Id,
                    Name             = "Spinner",
                    Description      = "Woha!",
                }
            };

            foreach (Attraction a in attractions)
            {
                var attractionsInDatabase = context.Attractions.Where
                                                (s => s.ParkInfo.Id == a.ParkInfoId).SingleOrDefault();
                if (attractionsInDatabase == null)
                {
                    context.Attractions.Add(a);
                }
            }
            context.SaveChanges();

            var avisits = new AttractionVisit[]
            {
                new AttractionVisit {
                    VisitDate = DateTime.Parse("2008-01-20"), AttractionId = attractions.Single(s => s.Name == "Spinner").Id, DailyReportId = dreports.Single(s => s.Date == DateTime.Parse("2009-10-03")).Id
                },
                new AttractionVisit {
                    VisitDate = DateTime.Parse("2008-01-20"), AttractionId = attractions.Single(s => s.Name == "Great View").Id, DailyReportId = dreports.Single(s => s.Date == DateTime.Parse("2009-10-03")).Id
                },
                new AttractionVisit {
                    VisitDate = DateTime.Parse("2008-01-20"), AttractionId = attractions.Single(s => s.Name == "Water Snake").Id, DailyReportId = dreports.Single(s => s.Date == DateTime.Parse("2009-10-03")).Id
                },
                new AttractionVisit {
                    VisitDate = DateTime.Parse("2008-01-20"), AttractionId = attractions.Single(s => s.Name == "Wild Ride").Id, DailyReportId = dreports.Single(s => s.Date == DateTime.Parse("2009-10-03")).Id
                },
                new AttractionVisit {
                    VisitDate = DateTime.Parse("2008-01-20"), AttractionId = attractions.Single(s => s.Name == "Spooky House").Id, DailyReportId = dreports.Single(s => s.Date == DateTime.Parse("2009-10-03")).Id
                }
            };

            foreach (AttractionVisit av in avisits)
            {
                var attractionVisitsInDatabase = context.AttractionVisits.Where
                                                     (s => s.Attraction.Id == av.AttractionId &&
                                                     s.DailyReport.Id == av.DailyReportId).SingleOrDefault();
                if (attractionVisitsInDatabase == null)
                {
                    context.AttractionVisits.Add(av);
                }
            }
            context.SaveChanges();

            var mrequest = new Maintenance[]
            {
                new Maintenance
                {
                    AttractionId  = 1,
                    Description   = "Spooky House as a leeky pipe",
                    DateRecieved  = DateTime.Parse("2009-10-03"),
                    DateResolved  = DateTime.Parse("2009-10-03"),
                    CurrentStatus = "Still leaky",
                    Cost          = 53.96m,
                    DailyReportId = dreports.Single(s => s.Date == DateTime.Parse("2009-10-03")).Id
                }
            };

            foreach (Maintenance m in mrequest)
            {
                var maintenanceInDatabase = context.Maintenances.Where
                                                (s => s.Attraction.Id == m.AttractionId &&
                                                s.DailyReport.Id == m.DailyReportId).SingleOrDefault();
                if (maintenanceInDatabase == null)
                {
                    context.Maintenances.Add(m);
                }
            }
            context.SaveChanges();

            var departments = new Department[]
            {
                new Department
                {
                    ParkInfoId = pinfo.Single(s => s.Name == "Houston Theme Park").Id,
                    LocationId = locations.Single(s => s.Name == "Center").Id,
                    Name       = "Management"
                },
                new Department
                {
                    ParkInfoId = pinfo.Single(s => s.Name == "Houston Theme Park").Id,
                    LocationId = locations.Single(s => s.Name == "West").Id,
                    Name       = "Maintenance"
                },
                new Department
                {
                    ParkInfoId = pinfo.Single(s => s.Name == "Houston Theme Park").Id,
                    LocationId = locations.Single(s => s.Name == "Center").Id,
                    Name       = "Ride Attendants"
                },
                new Department
                {
                    ParkInfoId = pinfo.Single(s => s.Name == "Houston Theme Park").Id,
                    LocationId = locations.Single(s => s.Name == "South").Id,
                    Name       = "Vendor Employee"
                }
            };

            foreach (Department d in departments)
            {
                var departmentsInDatabase = context.Departments.Where
                                                (s => s.ParkInfo.Id == d.ParkInfoId).SingleOrDefault();
                if (departmentsInDatabase == null)
                {
                    context.Departments.Add(d);
                }
            }
            context.SaveChanges();


            var employees = new Employee[]
            {
                new Employee
                {
                    FirstName    = "Juan",
                    LastName     = "Garcia",
                    Title        = "Ride Attendant",
                    DepartmentId = departments.Single(s => s.Name == "Ride Attendants").Id,
                    HireDate     = DateTime.Parse("2008-04-15"),
                    Salary       = 10.25m
                },
                new Employee
                {
                    FirstName     = "John",
                    MiddleInitial = "H",
                    LastName      = "Smith",
                    Title         = "Ride Attendant",
                    DepartmentId  = departments.Single(s => s.Name == "Ride Attendants").Id,
                    HireDate      = DateTime.Parse("2008-06-16"),
                    Salary        = 8.25m
                },
                new Employee
                {
                    FirstName    = "Sally",
                    LastName     = "Red",
                    Title        = "Ride Attendant",
                    DepartmentId = departments.Single(s => s.Name == "Ride Attendants").Id,
                    HireDate     = DateTime.Parse("2008-05-21"),
                    Salary       = 8.25m
                },
                new Employee
                {
                    FirstName    = "Nick",
                    LastName     = "Rodger",
                    Title        = "Maintenance Crew",
                    DepartmentId = departments.Single(s => s.Name == "Maintenance").Id,
                    HireDate     = DateTime.Parse("2007-09-25"),
                    Salary       = 18.75m
                },
                new Employee
                {
                    FirstName    = "David",
                    LastName     = "Valentino",
                    Title        = "Maintenance Crew",
                    DepartmentId = departments.Single(s => s.Name == "Maintenance").Id,
                    HireDate     = DateTime.Parse("2007-09-15"),
                    Salary       = 18.75m
                },
                new Employee
                {
                    FirstName    = "Leon",
                    LastName     = "Nobody",
                    Title        = "Vendor Cashier",
                    DepartmentId = departments.Single(s => s.Name == "Vendor Employee").Id,
                    HireDate     = DateTime.Parse("2008-02-07"),
                    Salary       = 10.25m
                },
                new Employee
                {
                    FirstName    = "Ashely",
                    LastName     = "Frutiz",
                    Title        = "Manager",
                    DepartmentId = departments.Single(s => s.Name == "Management").Id,
                    HireDate     = DateTime.Parse("2006-07-09"),
                    Salary       = 27.85m
                },
            };

            foreach (Employee e in employees)
            {
                var employeeInDatabase = context.Employees.Where
                                             (s => s.Department.Id == e.DepartmentId).SingleOrDefault();
                if (employeeInDatabase == null)
                {
                    context.Employees.Add(e);
                }
            }
            context.SaveChanges();

            var ttypes = new TicketType[]
            {
                new TicketType
                {
                    Name        = "Basic",
                    Description = "Basic, one time use ticket",
                    Price       = 5.00m,
                    Uses        = 1
                },
                new TicketType
                {
                    Name        = "30-Day",
                    Description = "30 day ticket, good for 30 uses",
                    Price       = 50.00m,
                    Uses        = 30
                },
                new TicketType
                {
                    Name        = "Premium",
                    Description = "Premium ticket, good for 180 uses",
                    Price       = 100.00m,
                    Uses        = 180
                }
            };

            foreach (TicketType tt in ttypes)
            {
                context.TicketTypes.Add(tt);
            }
            context.SaveChanges();

            var visitors = new Visitor[]
            {
                new Visitor
                {
                    FirstName   = "John",
                    LastName    = "Hop",
                    Email       = "*****@*****.**",
                    PhoneNumber = "1234567890",
                    DateOfBirth = DateTime.Parse("1988-04-15"),
                },
                new Visitor
                {
                    FirstName   = "John",
                    LastName    = "Hope",
                    Email       = "*****@*****.**",
                    PhoneNumber = "1234567890",
                    DateOfBirth = DateTime.Parse("1988-04-15"),
                },
                new Visitor
                {
                    FirstName   = "John",
                    LastName    = "Hopee",
                    Email       = "*****@*****.**",
                    PhoneNumber = "1234567890",
                    DateOfBirth = DateTime.Parse("1988-04-15"),
                },
                new Visitor
                {
                    FirstName   = "John",
                    LastName    = "Hopeee",
                    Email       = "*****@*****.**",
                    PhoneNumber = "1234567890",
                    DateOfBirth = DateTime.Parse("1988-04-15"),
                },
                new Visitor
                {
                    FirstName   = "Jeff",
                    LastName    = "Croft",
                    Email       = "*****@*****.**",
                    PhoneNumber = "1234567891",
                    DateOfBirth = DateTime.Parse("1989-04-15"),
                },
                new Visitor
                {
                    FirstName   = "Joe",
                    LastName    = "Person",
                    Email       = "*****@*****.**",
                    PhoneNumber = "1234567892",
                    DateOfBirth = DateTime.Parse("1990-04-15"),
                },
                new Visitor
                {
                    FirstName   = "Jane",
                    LastName    = "Mot",
                    Email       = "*****@*****.**",
                    PhoneNumber = "1234567893",
                    DateOfBirth = DateTime.Parse("1991-04-15"),
                },
                new Visitor
                {
                    FirstName   = "Jo",
                    LastName    = "Zi",
                    Email       = "*****@*****.**",
                    PhoneNumber = "1234567894",
                    DateOfBirth = DateTime.Parse("1992-04-15"),
                },
                new Visitor
                {
                    FirstName   = "Jello",
                    LastName    = "Yee",
                    Email       = "*****@*****.**",
                    PhoneNumber = "1234567895",
                    DateOfBirth = DateTime.Parse("1993-04-15"),
                },
                new Visitor
                {
                    FirstName   = "Jesus",
                    LastName    = "Xo",
                    Email       = "*****@*****.**",
                    PhoneNumber = "1234567896",
                    DateOfBirth = DateTime.Parse("1994-04-15"),
                }
            };

            foreach (Visitor vi in visitors)
            {
                context.Visitors.Add(vi);
            }
            context.SaveChanges();

            var tickets = new Ticket[]
            {
                new Ticket
                {
                    DatePurchased = DateTime.Parse("2009-10-03"),
                    TicketTypeId  = ttypes.Single(s => s.Name == "Basic").Id,
                    VisitorId     = visitors.Single(s => s.LastName == "Hop").Id,
                    DailyReportId = dreports.Single(s => s.Date == DateTime.Parse("2009-10-03")).Id
                },
                new Ticket
                {
                    DatePurchased = DateTime.Parse("2009-10-03"),
                    TicketTypeId  = ttypes.Single(s => s.Name == "Basic").Id,
                    VisitorId     = visitors.Single(s => s.LastName == "Hope").Id,
                    DailyReportId = dreports.Single(s => s.Date == DateTime.Parse("2009-10-03")).Id
                },
                new Ticket
                {
                    DatePurchased = DateTime.Parse("2009-10-03"),
                    TicketTypeId  = ttypes.Single(s => s.Name == "Basic").Id,
                    VisitorId     = visitors.Single(s => s.LastName == "Hopee").Id,
                    DailyReportId = dreports.Single(s => s.Date == DateTime.Parse("2009-10-03")).Id
                },
                new Ticket
                {
                    DatePurchased = DateTime.Parse("2009-10-03"),
                    TicketTypeId  = ttypes.Single(s => s.Name == "Basic").Id,
                    VisitorId     = visitors.Single(s => s.LastName == "Hopeee").Id,
                    DailyReportId = dreports.Single(s => s.Date == DateTime.Parse("2009-10-03")).Id
                },
                new Ticket
                {
                    DatePurchased = DateTime.Parse("2009-10-03"),
                    TicketTypeId  = ttypes.Single(s => s.Name == "Basic").Id,
                    VisitorId     = visitors.Single(s => s.LastName == "Croft").Id,
                    DailyReportId = dreports.Single(s => s.Date == DateTime.Parse("2009-10-03")).Id
                },
                new Ticket
                {
                    DatePurchased = DateTime.Parse("2009-10-03"),
                    TicketTypeId  = ttypes.Single(s => s.Name == "Basic").Id,
                    VisitorId     = visitors.Single(s => s.LastName == "Person").Id,
                    DailyReportId = dreports.Single(s => s.Date == DateTime.Parse("2009-10-03")).Id
                },

                new Ticket
                {
                    DatePurchased = DateTime.Parse("2009-10-03"),
                    TicketTypeId  = ttypes.Single(s => s.Name == "Basic").Id,
                    VisitorId     = visitors.Single(s => s.LastName == "Mot").Id,
                    DailyReportId = dreports.Single(s => s.Date == DateTime.Parse("2009-10-03")).Id
                },
                new Ticket
                {
                    DatePurchased = DateTime.Parse("2009-10-03"),
                    TicketTypeId  = ttypes.Single(s => s.Name == "30-Day").Id,
                    VisitorId     = visitors.Single(s => s.LastName == "Zi").Id,
                    DailyReportId = dreports.Single(s => s.Date == DateTime.Parse("2009-10-03")).Id
                },
                new Ticket
                {
                    DatePurchased = DateTime.Parse("2009-10-03"),
                    TicketTypeId  = ttypes.Single(s => s.Name == "30-Day").Id,
                    VisitorId     = visitors.Single(s => s.LastName == "Yee").Id,
                    DailyReportId = dreports.Single(s => s.Date == DateTime.Parse("2009-10-03")).Id
                },
                new Ticket
                {
                    DatePurchased = DateTime.Parse("2009-10-03"),
                    TicketTypeId  = ttypes.Single(s => s.Name == "Premium").Id,
                    VisitorId     = visitors.Single(s => s.LastName == "Xo").Id,
                    DailyReportId = dreports.Single(s => s.Date == DateTime.Parse("2009-10-03")).Id
                }
            };

            foreach (Ticket t in tickets)
            {
                var ticketSalesInDatabase = context.Tickets.Where(s => s.DailyReport.Id == t.DailyReportId).SingleOrDefault();
                if (ticketSalesInDatabase == null)
                {
                    context.Tickets.Add(t);
                }
            }
            context.SaveChanges();



            var vtypes = new VendorType[]
            {
                new VendorType {
                    Name = "Stand"
                },
                new VendorType {
                    Name = "Store"
                },
                new VendorType {
                    Name = "Game"
                },
            };

            foreach (VendorType vt in vtypes)
            {
                context.VendorTypes.Add(vt);
            }
            context.SaveChanges();


            var vendors = new Vendor[]
            {
                new Vendor
                {
                    ParkInfoId   = pinfo.Single(s => s.Name == "Houston Theme Park").Id,
                    Name         = "Tacos to Go",
                    Description  = "Sells tacos to people on the go",
                    LocationId   = locations.Single(s => s.Name == "West").Id,
                    VendorTypeId = vtypes.Single(s => s.Name == "Stand").Id,
                },
                new Vendor
                {
                    ParkInfoId   = pinfo.Single(s => s.Name == "Houston Theme Park").Id,
                    Name         = "Shoot Them All",
                    Description  = "Shoot down all the targets win prizes",
                    LocationId   = locations.Single(s => s.Name == "East").Id,
                    VendorTypeId = vtypes.Single(s => s.Name == "Game").Id,
                },
                new Vendor
                {
                    ParkInfoId   = pinfo.Single(s => s.Name == "Houston Theme Park").Id,
                    Name         = "Park Gifts",
                    Description  = "Gifts for your friends who couldn't be here",
                    LocationId   = locations.Single(s => s.Name == "Center").Id,
                    VendorTypeId = vtypes.Single(s => s.Name == "Store").Id,
                }
            };

            foreach (Vendor ve in vendors)
            {
                var vendorsInDatabase = context.Vendors.Where
                                            (s => s.ParkInfo.Id == ve.ParkInfoId).SingleOrDefault();
                if (vendorsInDatabase == null)
                {
                    context.Vendors.Add(ve);
                }
            }
            context.SaveChanges();

            var vsales = new VendorSale[]
            {
                new VendorSale
                {
                    ReportDate    = DateTime.Parse("2009-10-03"),
                    TotalSales    = 73.85m,
                    SalesGoal     = 100.00m,
                    VendorId      = vendors.Single(s => s.Name == "Park Gifts").Id,
                    DailyReportId = dreports.Single(s => s.Date == DateTime.Parse("2009-10-03")).Id
                },
                new VendorSale
                {
                    ReportDate    = DateTime.Parse("2009-10-03"),
                    TotalSales    = 150.00m,
                    SalesGoal     = 75.00m,
                    VendorId      = vendors.Single(s => s.Name == "Shoot Them All").Id,
                    DailyReportId = dreports.Single(s => s.Date == DateTime.Parse("2009-10-03")).Id
                },
                new VendorSale
                {
                    ReportDate    = DateTime.Parse("2009-10-03"),
                    TotalSales    = 100.00m,
                    SalesGoal     = 50.00m,
                    VendorId      = vendors.Single(s => s.Name == "Tacos to Go").Id,
                    DailyReportId = dreports.Single(s => s.Date == DateTime.Parse("2009-10-03")).Id
                }
            };

            foreach (VendorSale ve in vsales)
            {
                var vendorSalesInDatabase = context.VendorSales.Where
                                                (s => s.Vendor.Id == ve.VendorId &&
                                                s.DailyReport.Id == ve.DailyReportId).SingleOrDefault();
                if (vendorSalesInDatabase == null)
                {
                    context.VendorSales.Add(ve);
                }
            }
            context.SaveChanges();



            /*
             * var pinfo = new ParkInfo[]
             * {
             *  new ParkInfo
             *  {
             *      Name = "Houston Theme Park",
             *      Country = "USA",
             *      State = "TX",
             *      City = "Houston",
             *      ZipCode = "77042",
             *      StreetNumber = "11223",
             *      StreetName = "Grant Rd"
             *  },
             * };
             * foreach (ParkInfo pi in pinfo) { context.ParkInfo.Add(pi); }
             * context.SaveChanges();
             */
            /*
             * var dreports = new DailyReport[]
             * {
             *  new DailyReport
             *  {
             *      WeatherId = weather.Single(s => s.Date == DateTime.Parse("2009-10-03")).Id,
             *      Date = DateTime.Parse("2009-10-03")
             *  }
             * };
             *
             * foreach (DailyReport dr in dreports) { context.DailyReports.Add(dr); }
             *
             * context.SaveChanges();
             */
        }
Exemplo n.º 34
0
 public void brokenAttraction(Attraction attraction)
 {
     attractionObjective = attraction;
     goToAttraction();
     estado_trabajo = STATE_Working.DIRIGIENDOSE_ATRACCION;
 }
Exemplo n.º 35
0
        public static async Task GetCityAttractionAsync(LatLng latLng, string attraction, string uri, Action <CityAttractions> Callback)
        {
            string nextPageToken = null;

            // Create a temporary HttpClient connection.
            using (var Client = new HttpClient())
            {
                try
                {
                    // string placesApiKey = "AIzaSyAgsubmt3p8asFrV-x_x_cEInQokzf-X9s";

                    // https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=-33.8670,151.1957&radius=500&types=food&name=cruise&key=YOUR_API_KEY
                    // string uri = $"https://maps.googleapis.com/maps/api/place/nearbysearch/json?location={latLng.Latitude},{latLng.Longitude}&radius=100000&types={attraction}&key={placesApiKey}";
                    // https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=47.6101497,-122.2015159&radius=50000&types=park&rankby=prominence&key=AIzaSyAgsubmt3p8asFrV-x_x_cEInQokzf-X9s
                    // string uri = $"https://maps.googleapis.com/maps/api/place/nearbysearch/json?location={latLng.Latitude},{latLng.Longitude}&types={attraction}&rankby=distance&key={placesApiKey}";
                    // string uri = $"https://maps.googleapis.com/maps/api/place/nearbysearch/json?location={latLng.Latitude},{latLng.Longitude}&types={attraction}&radius=3200&key={placesApiKey}";
                    Client.BaseAddress = new Uri(uri);
                    HttpResponseMessage Response = await Client.GetAsync("");           // Make the actual API call.

                    Response.EnsureSuccessStatusCode();                                 // Throw error if not successful.
                    string StringResponse = await Response.Content.ReadAsStringAsync(); // Read in the response as a string.

                    JObject CityAttractionsObject = JsonConvert.DeserializeObject <JObject>(StringResponse);

                    // Console.WriteLine("results: " + CityAttractionsObject["results"]);
                    // Console.WriteLine("next_page_token: " + CityAttractionsObject["next_page_token"]);
                    if (CityAttractionsObject["next_page_token"] != null)
                    {
                        nextPageToken = CityAttractionsObject["next_page_token"].Value <string>();
                    }

                    JArray AttractionList = CityAttractionsObject["results"].Value <JArray>();

                    List <Attraction> Attractions = new List <Attraction>();

                    foreach (JObject AttractionObject in AttractionList)
                    {
                        Attraction newAttraction = new Attraction {
                            Name      = AttractionObject["name"].Value <string>(),
                            Vicinity  = AttractionObject["vicinity"].Value <string>(),
                            Latitude  = AttractionObject["geometry"]["location"]["lat"].Value <double>(),
                            Longitude = AttractionObject["geometry"]["location"]["lng"].Value <double>()
                        };

                        Attractions.Add(newAttraction);
                    }

                    // Console.WriteLine("results: " + CityAttractionsObject["results"]);
                    // Console.WriteLine("name: " + CityAttractionsObject["results"][0]["name"]);
                    // Console.WriteLine("name: " + CityAttractionsObject["results"][1]["name"]);
                    // Console.WriteLine("name: " + CityAttractionsObject["results"][2]["name"]);


                    CityAttractions CityAttractions = new CityAttractions {
                        Attraction    = attraction,
                        Attractions   = Attractions,
                        NextPageToken = nextPageToken
                    };

                    // Finally, execute our callback, passing it the response we got.
                    // Callback(JsonResponse);
                    Callback(CityAttractions);
                }
                catch (HttpRequestException e)
                {
                    // If something went wrong, display the error.
                    Console.WriteLine($"Request exception: {e.Message}");
                }
            }
        }