public static List <SlinkUser> GetMyConnections() { var me = RealmUserServices.GetMe(false); var realm = RealmManager.SharedInstance.GetRealm(null); var owners = realm.All <SlinkUser>().Where(c => !c.ID.Equals(me.ID, StringComparison.OrdinalIgnoreCase)).OrderBy(c => c.FacebookID).ToList(); var users = new List <SlinkUser>(); foreach (var owner in owners) { foreach (Card c in owner.Cards) { c.ShowFront(); } //name adjustment required cuz shlomo put the name of the user inside the name of the card var firstCard = owner.Cards.FirstOrDefault(); if (firstCard == null) { continue; } realm.Write(() => { owner.FirstName = firstCard.Name; }); users.Add(owner); } return(users); }
public static List <Card> GetMyCards(bool ForceToFront) { var realm = RealmManager.SharedInstance.GetRealm(null); var me = RealmUserServices.GetMe(false); if (me == null) { return(null); } var list = realm.All <Card>().Where(c => c.Owner == me && c.Deleted == false).OrderBy(c => c.Name); if (ForceToFront) { realm.Write(() => { foreach (Card card in list) { card.IsFlipped = false; } }); } var returnList = list.ToList(); return(returnList); }
public static IList <Outlet> GetMyOutlets() { var realm = RealmManager.SharedInstance.GetRealm(null); var me = RealmUserServices.GetMe(false); if (me == null) { return(null); } //make sure facebook outlet exists realm.Write(() => { foreach (var facebookOutlet in me.Outlets.Where(o => o.Type.Equals(Outlet.outlet_type_facebook, StringComparison.OrdinalIgnoreCase))) { facebookOutlet.Deleted = false; } }); var list = me.Outlets.Where(c => c.Deleted == false).ToList(); if (CrossDeviceInfo.Current.Platform == Platform.Android) { list.Add(null); } return(list); }
public void NextPage() { var realm = RealmManager.SharedInstance.GetRealm(null); var me = RealmUserServices.GetMe(true); if (!String.IsNullOrEmpty(FacebookFirstName) || !String.IsNullOrEmpty(FacebookLastName)) { realm.Write(() => { if (!String.IsNullOrEmpty(FacebookUserId)) me.FacebookID = FacebookUserId; if (!String.IsNullOrEmpty(FacebookFirstName)) me.FirstName = FacebookFirstName; if (!String.IsNullOrEmpty(FacebookLastName)) me.LastName = FacebookLastName; }); } var outlet = new Outlet(); outlet.Name = FacebookFullName; outlet.Handle = FacebookUserId; outlet.Locked = true; outlet.Type = Outlet.outlet_type_facebook; RealmServices.SaveOutlet(outlet); }
public static Card Create() { var me = RealmUserServices.GetMe(false); if (me == null) { return(null); } var card = new Card(); card.CompanyNameTextColor = ColorUtils.ToHexString(ColorUtils.GetColor(ColorUtils.ColorType.Black)); card.BorderColor = ColorUtils.ToHexString(ColorUtils.GetColor(ColorUtils.ColorType.White)); card.BackgroundColor = ColorUtils.ToHexString(ColorUtils.GetColor(ColorUtils.ColorType.White)); card.Name = Strings.Basic.new_card; card.UUID = Guid.NewGuid().ToString(); card.UserDisplayName = me.Name; card.Retained = true; var realm = RealmManager.SharedInstance.GetRealm(null); realm.Write(() => { realm.Add(card); }); return(card); }
public static bool SaveOutlet(Outlet outlet) { if (outlet == null) { return(false); } if (String.IsNullOrEmpty(outlet.Handle)) { return(false); } var realm = RealmManager.SharedInstance.GetRealm(null); if (realm == null) { return(false); } var me = RealmUserServices.GetMe(false); if (me == null) { return(false); } var existingOutlet = me.Outlets.Where( c => c.Type != null && c.Type.Equals(outlet.Type, StringComparison.OrdinalIgnoreCase) && c.Handle != null && c.Handle.Equals(outlet.Handle, StringComparison.OrdinalIgnoreCase) ).FirstOrDefault(); if (existingOutlet != null) { realm.Write(() => { existingOutlet.Deleted = false; }); } else { realm.Write(() => { realm.Add(outlet); me.Outlets.Add(outlet); }); Transporter.SharedInstance.SetObject(Transporter.NewOutletAddedValueTransporterKey, outlet); return(true); } return(false); }
async public static Task <string> BoardcastCard(Card card, string UUID) { var permissionStatus = await CrossPermissions.Current.CheckPermissionStatusAsync(Permission.Location); if (permissionStatus != PermissionStatus.Granted) { return(null); } var locator = CrossGeolocator.Current; locator.DesiredAccuracy = 50; Position position = null; try { position = await locator.GetPositionAsync(TimeSpan.FromSeconds(10)); } catch (Exception e) { AppCenterManager.Report(e); } if (position == null) { return(null); } var lat = position.Latitude; var lon = position.Longitude; var time = DateTimeOffset.UtcNow; System.Diagnostics.Debug.WriteLine("Lat: " + lat, " Lon: " + lon); //get users name to replace the card name var me = RealmUserServices.GetMe(false); if (me == null) { return(null); } await WebServices.UserController.UpdateUser(lat, lon); var transactionId = await WebServices.TransactionsController.CreateTransaction(lat, lon, card, me.Name); return(transactionId); }
public static void SetNextHandelByNameIfNecessary() { var me = RealmUserServices.GetMe(false); if (me == null) { return; } if (!String.IsNullOrEmpty(me.Handle)) { return; } if (String.IsNullOrEmpty(me.FirstName) || String.IsNullOrEmpty(me.LastName)) { throw new Exception("User Information Incomplete"); } string finalHandel = null; int suffix = 0; string potentialHandle = "@" + me.FirstName + "_" + me.LastName; var realm = RealmManager.SharedInstance.GetRealm(null); while (String.IsNullOrEmpty(finalHandel)) { var userWithHandleFound = realm.All <SlinkUser>().Where(u => u.Handle.Equals(potentialHandle, StringComparison.OrdinalIgnoreCase)).FirstOrDefault(); if (userWithHandleFound == null) //no user was found { finalHandel = potentialHandle; break; } suffix++; potentialHandle = "@" + me.FirstName + "_" + me.LastName + suffix; } realm.Write(() => { me.Handle = finalHandel; }); }
public static List <Outlet> GetAllAvailableOutlets() { var me = RealmUserServices.GetMe(false); if (me == null) { return(null); } var returnList = new List <Outlet>(); var facebook = new Outlet(); facebook.Type = Outlet.outlet_type_facebook; facebook.AvailbleForAddition = me.Outlets.Where(o => o.Type.Equals(Outlet.outlet_type_facebook, StringComparison.OrdinalIgnoreCase)).Count() == 0; returnList.Add(facebook); var instagram = new Outlet(); instagram.Type = Outlet.outlet_type_instagram; instagram.AvailbleForAddition = true; returnList.Add(instagram); var website = new Outlet(); website.Type = Outlet.outlet_type_website; website.AvailbleForAddition = true; returnList.Add(website); var email = new Outlet(); email.Type = Outlet.outlet_type_email; email.AvailbleForAddition = true; returnList.Add(email); var github = new Outlet(); github.Type = Outlet.outlet_type_github; github.AvailbleForAddition = true; returnList.Add(github); var twitter = new Outlet(); twitter.Type = Outlet.outlet_type_twitter; twitter.AvailbleForAddition = true; returnList.Add(twitter); var linkedIn = new Outlet(); linkedIn.Type = Outlet.outlet_type_linkedIn; linkedIn.AvailbleForAddition = true; returnList.Add(linkedIn); var pinterest = new Outlet(); pinterest.Type = Outlet.outlet_type_pinterest; pinterest.AvailbleForAddition = true; returnList.Add(pinterest); var google = new Outlet(); google.Type = Outlet.outlet_type_google; google.AvailbleForAddition = true; returnList.Add(google); var phone = new Outlet(); phone.Type = Outlet.outlet_type_phone; phone.AvailbleForAddition = true; returnList.Add(phone); return(returnList.OrderBy(c => c.Type).ToList()); }
async public Task GetNearbyTransactions() { if (QueryLock) { return; } QueryLock = true; try { var locator = CrossGeolocator.Current; locator.DesiredAccuracy = 50; var position = await locator.GetPositionAsync(TimeSpan.FromSeconds(10)); if (position == null) { return; } var lat = position.Latitude; var lon = position.Longitude; var me = RealmUserServices.GetMe(false); if (me == null) { return; } var id = ServiceLocator.Instance.Resolve <IPersistantStorage>().GetUserId(); if (String.IsNullOrEmpty(id)) { return; } await WebServices.UserController.UpdateUser(lat, lon); await WebServices.TransactionsController.GetTranactions(AllItems); var cards = RealmServices.GetUnretainedCards(); var filteredCards = FilterCards(cards); System.Diagnostics.Debug.WriteLine("cards count: " + filteredCards.Count()); foreach (var card in filteredCards) { //don't show my own broadcasts var isMine = card.Owner.FacebookID.Equals(id, StringComparison.OrdinalIgnoreCase); if (isMine) { continue; } var model = new DiscoverModel(); model.Card = card; TableItems.Add(model); } } catch (Exception e) { System.Diagnostics.Debug.WriteLine(e.Message); } QueryLock = false; }