public BuddyImporterController(IBuddyImporterView view, BuddyImporterService service)
		{
			this.view = view;
			this.view.Load += new EventHandler(view_Load);
			this.view.GetEmailContacts += new EventHandler(view_GetEmailContacts);
			this.view.AddBuddiesAndInviteContacts += new EventHandler(view_AddBuddiesAndInviteContacts);
			this.service = service;
		}
Exemplo n.º 2
0
		public void Test()
		{
			BuddyImporterService service = new BuddyImporterService();
			string email = "*****@*****.**";

			Usr u = new Usr();
			u.Update();

			Usr u2 = new Usr()
			{
				Email = email
			};
			u2.Update();

			Buddy b = new Buddy()
			{
				UsrK = u.K,
				BuddyUsrK = u2.K
			};
			b.Update();

			List<Contact> cList;
			List<Usr> uList;

			List<Contact> list = new List<Contact>()
			{
				new Contact("Bob", email)
			};

			int alreadyBuddies;
			service.SplitOutEmailContacts(list, u.K, out alreadyBuddies, out uList, out cList);

			Assert.AreEqual(1, uList.Count);
			Assert.IsTrue((bool)uList[0].ExtraSelectElements["BuddyRequested"]);
			Assert.AreEqual(0, cList.Count);
		}
Exemplo n.º 3
0
		private int CreateUsrFromEmail(string text, bool addAsBuddy)
		{
			string email = text;
			string name = name = email.TruncateWithDots(10);
			int indexOfFirstSpace = text.IndexOf(' ');
			if (indexOfFirstSpace >= 0)
			{
				email = text.Substring(0, indexOfFirstSpace);
				name = text.Substring(indexOfFirstSpace + 1);
			}
			Regex emailRegex = new Regex(Cambro.Misc.RegEx.Email);
			if (!emailRegex.IsMatch(email))
			{
				throw new Exception(email + "is not a valid email address. ALERT");
			}
			else
			{
				var usrSet = new UsrSet(new Query(new Q(Bobs.Usr.Columns.Email, email)));
				if (usrSet.Count == 0)
				{
					var service = new BuddyImporterService();
					service.InviteContacts(Usr.Current, new List<Contact>() { new Contact(name, email) });
					usrSet = new UsrSet(new Query(new Q(Bobs.Usr.Columns.Email, email)));
				}
				Usr newUsr = usrSet[0];
				if (addAsBuddy)
				{
					try
					{
						Buddy buddy = new Buddy(Usr.Current.K, newUsr.K);
					}
					catch (BobNotFound)
					{
						Usr.Current.AddBuddy(newUsr, true, true, Usr.AddBuddySource.BuddyAutoComplete, Buddy.BuddyFindingMethod.EmailAddress, name);
					}
				}
				return usrSet[0].K;
			}
		}