//Organization organization;
		//string ID;

		public EventListView(Profile pro)
		{
			InitializeComponent();
			profile = pro;
			currentView = 4;
			setUp();
		}
		public async Task<bool> CreateUpdateProfile(Profile pro, bool create)
		{
			var uri = "?create="+create;
			Profile newPro = new Profile() { Name = pro.Name, Description = pro.Description, ProfileId = pro.ProfileId, ImageSource = pro.ImageSource };
			var content = JsonConvert.SerializeObject(newPro);

			var recievedContent = "";
			try
			{
				var response = await httpClient.PostAsync(new Uri(App.serverUri + "profile" + uri), new StringContent(content, Encoding.UTF8, "application/json"));
				if (response.IsSuccessStatusCode)
				{
					if(create) await App.storeApiKey(JsonConvert.DeserializeObject<String>(await response.Content.ReadAsStringAsync()));
					return true;
				}
				else
				{
					await App.coreView.displayAlertMessage("Connection Error", "Trouble Connecting To Server", "OK");
				}
			}
			catch (Exception ex)
			{
				System.Diagnostics.Debug.WriteLine(@"				ERROR {0}", ex.Message);
			}
			return false;
		}
		public ProfileDesignView(Profile profile, Event eveInvitingTo, int dims) : base(dims)
		{
			this.profile = profile;
			design = Design.NameAndButtons;
			SetupButtons(true);
			if (!eveInvitingTo.Attendees.Exists(p => p.ProfileId == profile.ProfileId))
			{
				HandleButtonRequests(delegate ()
				{
					return _dataManager.EventApiManager.InviteProfilesToEvent(eveInvitingTo.EventId, new List<Profile> { profile });
				}, addBtn, "Invite", "Invited");
			}
		}
		public ProfileDesignView(Profile profile, Group grpInvitingTo, int dims) : base(dims)
		{
			this.profile = profile;
			design = Design.NameAndButtons;
			SetupButtons(true);
			if (grpInvitingTo.ProfilesRequestingToJoin.Exists(p => p.ProfileId == profile.ProfileId))
			{
				HandleButtonRequests(delegate ()
				{
					return _dataManager.GroupApiManager.InviteDeclineToGroup(grpInvitingTo.GroupId, true, new List<Profile> { profile });
				}, addBtn, "Accept", "Acceptd");
				HandleButtonRequests(delegate ()
				{
					return _dataManager.GroupApiManager.InviteDeclineToGroup(grpInvitingTo.GroupId, false, new List<Profile> { profile });
				}, removeBtn, "Decline", "Declined");
			} else  if (!grpInvitingTo.Members.Exists(p => p.ProfileId == profile.ProfileId))
			{
				HandleButtonRequests(delegate ()
				{
					return _dataManager.GroupApiManager.InviteDeclineToGroup(grpInvitingTo.GroupId, true, new List<Profile> { profile });
				}, addBtn, "Invite", "Invited");
			}
			setPillButtonLayout(new List<Button>() {addBtn, removeBtn });
		}
Example #5
0
		private async Task startProgram(CoreView coreView)
		{
			userProfile = await _dataManager.ProfileApiManager.GetLoggedInProfile ();
			coreView.startCoreView ();
			//coreView.setContentView (new EventView(), "Event");

		}
Example #6
0
		private async void LoginPage_LoginSucceeded(object sender, EventArgs e)
        {

           // await storeToken();

			var success = false;
			int tries = 0;

			while (!success)
			{

				Profile profile = new Profile() { ProfileId = StoredUserFacebookId, Name = StoredUserFacebookName, Age = 0, 
					SmallImageSource = "https://graph.facebook.com/v2.5/" + StoredUserFacebookId + "/picture?height=500&width=50",
					ImageSource = "https://graph.facebook.com/v2.5/" + StoredUserFacebookId + "/picture?height=100&width=100",
					LargeImageSource = "https://graph.facebook.com/v2.5/" + StoredUserFacebookId + "/picture?height=300&width=300"
				};
				success = await _dataManager.ProfileApiManager.CreateUpdateProfile(profile, true);

			}
			_dataManager = new DataManager();
			success = false;
			while (!success)
			{
				success = await _dataManager.ProfileApiManager.RegisterForNotifications(StoredNotificationToken);
				tries++;
				if (tries > 5) break;
			}


			coreView = new CoreView();
			coreView.token = StoredNotificationToken.DeviceToken + ", " + success;
			MainPage = coreView;
			startProgram(coreView);
			/*
			coreView = new CoreView();
			MainPage = coreView;
			coreView.setContentView (null, "SearchEvent");
			*/
        }
		/*
		public ProfileDesignView(Profile profile, Organization orgInvitingTo, int dims) : base(dims)
		{
			this.profile = profile;
			design = Design.NameAndButtons;
			SetupButtons(true);
			if (!orgInvitingTo.Members.Exists(p => p.ProfileId == profile.ProfileId))
			{
				HandleButtonRequests(delegate ()
				{
					return _dataManager.OrganizationApiManager.InviteToOrganization(orgInvitingTo.OrganizationId, profile);
				}, addBtn, "Invite", "Invited");
			} 
		} */

		public ProfileDesignView(Profile profile, int dims, bool clickable, Design design) : base(dims)
		{
			this.profile = profile;
			this.design = design;
			SetupButtons(clickable);
			if (profile.ProfileId != App.StoredUserFacebookId)
			{
				if (App.userProfile.RecievedFriendRequests != null && App.userProfile.RecievedFriendRequests.Exists(p => p.ProfileId == profile.ProfileId))
				{
					addBtn.Clicked += async (sender, e) =>
					{
						await _dataManager.ProfileApiManager.RequestDeclineAcceptUnfriend(profile.ProfileId, true);
						if (clickable)
						{
							await App.coreView.updateHomeView();
							App.coreView.setContentView(4);
						}
						else {
							App.coreView.setContentViewWithQueue(new InspectController(profile));
						}
					};


					HandleButtonRequests(delegate ()
					{
						return _dataManager.ProfileApiManager.RequestDeclineAcceptUnfriend(profile.ProfileId, true);
					}, addBtn, "Accept", "Accepted");
					HandleButtonRequests(delegate ()
					{
						return _dataManager.ProfileApiManager.RequestDeclineAcceptUnfriend(profile.ProfileId, false);
					}, removeBtn, "Decline", "Declined");
				}
				else if (App.userProfile.SentFriendRequests != null && App.userProfile.SentFriendRequests.Exists(p => p.ProfileId == profile.ProfileId))
				{
					HandleButtonRequests(delegate ()
					{
						return _dataManager.ProfileApiManager.RequestDeclineAcceptUnfriend(profile.ProfileId, false);
					}, addBtn, "Cancel Request", "Canceled");
				}
				else if (App.userProfile.Friends.Exists(p => p.ProfileId == profile.ProfileId))
				{
					HandleButtonRequests(delegate ()
					{
						return _dataManager.ProfileApiManager.RequestDeclineAcceptUnfriend(profile.ProfileId, false);
					}, removeBtn, "Remove", "Removed");
				}
				else {
					HandleButtonRequests(delegate ()
					{
						return _dataManager.ProfileApiManager.RequestDeclineAcceptUnfriend(profile.ProfileId, true);
					}, addBtn, "Add", "RequestSent");
				}
			} else {
				if (profile.ProfileId == App.userProfile.ProfileId && dims >= 200)
				{
					editBtn.IsVisible = true;
					/*
					bool edit = false;
					App.coreView.topBar.setRightButton("ic_menu.png").Clicked += async (sender, e) =>
					{
						List<Action> actions = new List<Action>();
						List<string> titles = new List<string>();
						List<string> images = new List<string>();

						actions.Add(() =>
						{
							ShowHideEditLayout(!edit);
							if (edit)
							{
								SetInfo(profile.ImageSource, profile.Name, profile.Description, design, ModelType.Profile);
							}
							edit = !edit;
						});
						titles.Add("Edit");
						images.Add("ic_settings.png");

						await App.coreView.DisplayOptions(actions, titles, images);
					}; */
				}
			}
		}
		public async void SetupButtons(bool clickable)
		{

			profile = await _dataManager.ProfileApiManager.GetProfile(profile.ProfileId);

			subjBtn.Clicked += (sender, e) =>
			{
				if (clickable)
				{
					_dataManager.setUpdateSeen(profile.ProfileId, NotificationModelType.Profile);
					App.coreView.setContentViewWithQueue(new InspectController(profile));
				}
				else {
					OtherFunctions of = new OtherFunctions();
					of.ViewImages(new List<string>() { profile.ImageSource });
				}
			};

			Profile updateProfile = App.userProfile;
			bool edit = false;

			editBtn.Text = "Edit";
			editBtn.Clicked += (sender, e) => { 
				ShowHideEditLayout(!edit);
				if (edit)
				{
					SetInfo(profile.ImageSource, profile.Name, profile.Description, design, ModelType.Profile);
				}
				edit = !edit;
			};

			var pictureImage = new TapGestureRecognizer();
			pictureImage.Tapped += async (sender, e) =>
			{
				imageStreams = await _dataManager.UtilityManager.TakePicture(profileImage.Source);
			};
			pictureButton.GestureRecognizers.Add(pictureImage);

			var albumImage = new TapGestureRecognizer();
			albumImage.Tapped += async (SenderOfEvent, e) =>
			{
				imageStreams = await _dataManager.UtilityManager.PictureFromAlbum(profileImage.Source);
			};
			albumButton.GestureRecognizers.Add(albumImage);

			fbImageButton.Clicked += (sender, e) =>
			{
				updateProfile.SmallImageSource = "https://graph.facebook.com/v2.5/" + App.userProfile.ProfileId + "/picture?height=50&width=50";
				updateProfile.ImageSource = "https://graph.facebook.com/v2.5/" + App.userProfile.ProfileId + "/picture?height=100&width=100";
				updateProfile.LargeImageSource = "https://graph.facebook.com/v2.5/" + App.userProfile.ProfileId + "/picture?height=300&width=300";
				profileImage.Source = updateProfile.ImageSource;
				imageStreams = null;
			};

			updateProfileBtn.Clicked += async  (sender, e) =>
			{
				App.coreView.IsLoading(true);
				if (imageStreams != null)
				{
					updateProfile.SmallImageSource = await _dataManager.UtilityManager.UploadImageToStorage(new MemoryStream(imageStreams[0]), App.StoredUserFacebookId + "." + DateTime.Now.ToString("G") + ".small");
					updateProfile.ImageSource = await _dataManager.UtilityManager.UploadImageToStorage(new MemoryStream(imageStreams[1]), App.StoredUserFacebookId + "." + DateTime.Now.ToString("G")+".medium");
					updateProfile.LargeImageSource = await _dataManager.UtilityManager.UploadImageToStorage(new MemoryStream(imageStreams[2]), App.StoredUserFacebookId + "." + DateTime.Now.ToString("G") + ".large");
				}
				updateProfile.Description = descriptionEdit.Text;
				bool success = await _dataManager.ProfileApiManager.CreateUpdateProfile(updateProfile, false);
				if (success)
				{
					//App.coreView.homeView = new HomeView();
					await App.coreView.updateHomeView();
					App.coreView.setContentView(4);
				}
				App.coreView.IsLoading(false);

				ShowHideEditLayout(false);
				edit = false;
			};

			profileLogOutBtn.Clicked += async (sender, e) =>
			{
				await App.storeToken("","","");
				await Navigation.PushModalAsync(new LoginPage());
			};

			try
			{
				//profile = await _dataManager.ProfileApiManager.GetProfile(profile.ProfileId);
				string d = profile.Description != null ? profile.Description : "";
				SetInfo(profile.ImageSource, profile.Name, d, design, ModelType.Profile);
			}
			catch (Exception e) {}
		}
		async void SetProfileInspect(Profile userProfile)
		{
			try {
				System.Diagnostics.Debug.WriteLine("ID: " + userProfile.ProfileId);
				Title = userProfile.Name;
				if (userProfile.ProfileId == App.StoredUserFacebookId) { 
					userProfile = App.userProfile; 
				}
				else { 
					userProfile = await _dataManager.ProfileApiManager.GetProfile(userProfile.ProfileId); 
				}
				infoView.Content = new ProfileDesignView(userProfile, 200, false, GenericDesignView.Design.ShowAll);
				infoView.Padding = new Thickness(0, 10, 0, 0);

				if (userProfile.ProfileId == App.userProfile.ProfileId)
				{
					userProfilerBeingViewed = true;
					if (userProfile.RecievedFriendRequests != null && userProfile.RecievedFriendRequests.Count > 0)
					{
						addNewElement(new ListsAndButtons(userProfile.RecievedFriendRequests, null, true, true), "Friend Requests", userProfile.RecievedFriendRequests.Count);
					}
					if (userProfile.GroupsInviteToAsOwner != null && userProfile.GroupsInviteToAsOwner.Count > 0)
					{
						addNewElement(new ListsAndButtons(null, userProfile.GroupsInviteToAsOwner, true, true), "Groups Invited To As Owner", userProfile.GroupsInviteToAsOwner.Count);
					}
					if (userProfile.GroupsInviteTo != null && userProfile.GroupsInviteTo.Count > 0)
					{
						addNewElement(new ListsAndButtons(null, userProfile.GroupsInviteTo, true, true), "Groups Invited To", userProfile.GroupsInviteTo.Count);
					}

					addNewElement(new ListsAndButtons(userProfile.Friends, null, true, false), "Friends", userProfile.Friends.Count);
					userProfile.GroupsOwned.AddRange(userProfile.Groups);
					addNewElement(new ListsAndButtons(null, userProfile.GroupsOwned, true, false), "Groups", userProfile.Groups.Count);
					//addNewElement(new ListsAndButtons(null, null, userProfile.Organizations, true, false), "Organizations", userProfile.Organizations.Count);
					addNewElement(new EventListView(userProfile), "Events", 0);
				}
				else if (App.userProfile.Friends.Exists(p => p.ProfileId == userProfile.ProfileId))
				{
					if (userProfile.Friends.Count > 0)
					{
						addNewElement(new ListsAndButtons(userProfile.Friends, null, true, false), "Friends", userProfile.Friends.Count);
					}
					addNewElement(new EventListView(userProfile), "Events", 0);
				}

				if (userProfile.ProfileId != App.userProfile.ProfileId)
				{
					App.coreView.IsLoading(true);
					message.IsVisible = true;
					var msImg = new TapGestureRecognizer();
					msImg.Tapped += async (sender, e) =>
					{
						Conversation conv = await _dataManager.MessageApiManager.CreateConversations(ConversationModelType.Profile, new List<Profile>() { App.userProfile, userProfile }, "", "");
						App.coreView.setContentViewWithQueue(new ConversationView(conv));
						/*
						Conversation conv = App.coreView.conversatios.conList.Find(c => c.Profiles.Count == 2 && c.Profiles.Exists(p => p.ProfileId == userProfile.ProfileId));
						if (conv == null)
						{
							conv = await _dataManager.MessageApiManager.CreateConversations(ConversationModelType.Profile, new List<Profile>() { App.userProfile, userProfile }, "", "");
						}
						if (conv != null)
						{
							App.coreView.setContentViewWithQueue(new ConversationView(conv), "", null);
						}
						*/
					};
					message.GestureRecognizers.Add(msImg);
					App.coreView.IsLoading(false);
				}
			}
			catch (Exception ex)
			{
				App.coreView.displayAlertMessage("Error", "Error loading content", "Ok");
				App.coreView.returnToPreviousView();
			}
		}
Example #10
0
		public bool HaveYouSentProfileFriendRequest(Profile profile)
		{
			bool requested = false;
			var yourSentFriendRequests = App.userProfile.SentFriendRequests;
			for (int i = 0; i < yourSentFriendRequests.Count; i++) {
				if (profile.ProfileId == yourSentFriendRequests [i].ProfileId) {
					requested = true;
				}
			}
			return requested;
		}
		public InspectController(Profile userProfile)
		{
			InitializeComponent();
			SetProfileInspect(userProfile);
		}
Example #12
0
		public bool HasProfileSentYouFriendRequest(Profile profile)
		{
			bool requested = false;
			var yourRecievedFriendRequests = App.userProfile.RecievedFriendRequests;
			for (int i = 0; i < yourRecievedFriendRequests.Count; i++) {
				if (profile.ProfileId == yourRecievedFriendRequests [i].ProfileId) {
					requested = true;
				}
			}
			return requested;
		}
Example #13
0
		public bool IsProfileFriend(Profile profile)
		{
			bool friend = false;
			var yourFriends = App.userProfile.Friends;
			for (int i = 0; i < yourFriends.Count; i++) {
				if (profile.ProfileId == yourFriends [i].ProfileId) {
					friend = true;
				}
			}
			return friend;
		}
Example #14
0
		public bool IsProfileYou(Profile profile)
		{
			bool you = false;
			if (profile.ProfileId == App.userProfile.ProfileId) {
				you = true;
			}
			return you;
		}
Example #15
0
		private async Task loadUpdatedProfile(Profile profile)
		{
			App.userProfile = await ProfileApiManager.GetLoggedInProfile ();
			InspectController inspect = new InspectController(profile);
			App.coreView.setContentViewWithQueue (inspect);
		}
Example #16
0
		public async Task<bool> addFriendRequest(Profile profile, bool acceptOrDecline)
		{
			bool success = await ProfileApiManager.RequestDeclineAcceptUnfriend(profile.ProfileId, acceptOrDecline);
			if (success) {
				App.userProfile = await ProfileApiManager.GetLoggedInProfile ();
				await loadUpdatedProfile(profile);
				App.coreView.setContentViewReplaceCurrent(new InspectController(profile), 1);
				App.coreView.updateHomeView();
			} else {
				await App.coreView.displayAlertMessage ("Error", "Something happened and the friend request was not sent, try again.", "Ok");
			}
			return success;
		}