Beispiel #1
0
 public void SendAll()
 {
     while (Emails.Any())
     {
         EmailGateway.Send(Emails.Dequeue());
     }
 }
        public IEnumerable <ValidationResult> Validate(ValidationContext validationContext)
        {
            if (!Emails.Any())
            {
                yield return(new ValidationResult("An email is required."));
            }

            if (Emails.Count() > 20)
            {
                yield return(new ValidationResult("You can only invite up to 20 users at a time."));
            }

            var attr = new EmailAddressAttribute();

            for (var i = 0; i < Emails.Count(); i++)
            {
                var email = Emails.ElementAt(i);
                if (!attr.IsValid(email) || email.Contains(" ") || email.Contains("<"))
                {
                    yield return(new ValidationResult($"Email #{i + 1} is not valid.",
                                                      new string[] { nameof(Emails) }));
                }
                else if (email.Length > 256)
                {
                    yield return(new ValidationResult($"Email #{i + 1} is longer than 256 characters.",
                                                      new string[] { nameof(Emails) }));
                }
            }
        }
Beispiel #3
0
 public EmailAddress GetEmail(string value)
 {
     if (Emails == null || !Emails.Any())
     {
         return(null);
     }
     return(Emails.ByValue(value));
 }
Beispiel #4
0
 public void AdicionarEmail(EEmailTipo tipo, string endereco)
 {
     if (Emails.Any(e => e.Endereco == endereco))
     {
         throw new Email.JaExisteException();
     }
     Emails.Add(new Email(tipo, endereco));
 }
 public User AddMail(Email email)
 {
     if (Emails.Any(x => x.Value == email.Value))
     {
         throw new BusinessException("Email is already exist!");
     }
     Emails.Add(email);
     return(this);
 }
Beispiel #6
0
        /// <summary>
        ///
        /// </summary>
        protected override void OnInitialized()
        {
            base.OnInitialized();

            Items = GenerateItems((int)(Count ?? 10));
            Emails ??= Array.Empty <string>();

            SelectedRows = Items.Where(i => Emails.Any(mail => mail == i.Email));
        }
Beispiel #7
0
        public Task <TabPerson> ToPerson()
        {
            if (person != null)
            {
                return(person.Task);
            }

            person = new TaskCompletionSource <TabPerson> ();
            var recipientQuery = new ParseQuery("Person");

            recipientQuery.SetCachePolicy(ParseQuery.CachePolicy.CacheElseNetwork);
            if (Emails.Any())
            {
                recipientQuery.WhereContainedIn("emails", Emails.Select(TabPerson.MD5Hash).ToArray());
            }
            else
            {
                recipientQuery.WhereEqualTo("displayName", DisplayName);
            }

            ParseObject recipient       = null;
            TabPerson   recipientPerson = null;

            recipientQuery.GetFirstInBackground(new TabGetCallback((o, e) => {
                if (o != null)
                {
                    recipient       = o;
                    recipientPerson = TabPerson.FromParse(recipient);
                    // TODO: add the emails that are in Emails and not in recipientPerson.Emails
                    person.SetResult(recipientPerson);
                }
                else
                {
                    recipientPerson = new TabPerson {
                        DisplayName = DisplayName,
                        Emails      = Emails,
                    };
                    recipient = recipientPerson.ToParse();
                    recipient.SaveInBackground(new TabSaveCallback(ex => {
                        if (ex == null)
                        {
                            person.SetResult(recipientPerson);
                        }
                        else
                        {
                            Android.Util.Log.Error("PersonCreator", ex.ToString());
                            person.SetException(ex);
                        }
                    }));
                    recipientQuery.ClearCachedResult();
                }
            }));

            return(person.Task);
        }
Beispiel #8
0
        /// <summary>
        ///
        /// </summary>
        protected override void OnInitialized()
        {
            base.OnInitialized();

            var context = BodyContext as FooContext;

            Items  = GenerateItems(context?.Count ?? 10);
            Emails = context?.Emails?.Split(";") ?? Array.Empty <string>();

            SelectedRows = Items.Where(i => Emails.Any(mail => mail == i.Email));
        }
Beispiel #9
0
 public override IEnumerable <ValidationResult> Validate(ValidationContext validationContext)
 {
     if (string.IsNullOrWhiteSpace(FirstName))
     {
         yield return(new ValidationResult("Firstname is required",
                                           new[] { nameof(FirstName) }));
     }
     if (IsDeveloper && !Emails.Any())
     {
         yield return(new ValidationResult("A developer must have an email address",
                                           new [] { nameof(IsDeveloper), nameof(Emails) }));
     }
 }
        public void ConfirmEmail(Email email)
        {
            var exist = Emails.Any(item => item.Equals(email));

            if (exist)
            {
                Emails.Remove(email);
                Emails.Add(email);
            }
            else
            {
                throw new InvalidOperationException("Email not exist");
            }

            PendingEvents.Enqueue(new EmailWasConfirmed(AggregatedId, new { Email = email }));
        }
Beispiel #11
0
    private Task <QueryData <Foo> > OnQueryAsync(QueryPageOptions option)
    {
        // 模拟查询数据
        var context = BodyContext as FooContext;

        Items = GenerateItems(context?.Count ?? 10);
        var data = new QueryData <Foo>()
        {
            TotalCount = Items.Count,
            Items      = Items
        };

        // 处理选中行
        Emails = context?.Emails?.Split(";") ?? Array.Empty <string>();
        SelectedRows.AddRange(Items.Where(i => Emails.Any(mail => mail == i.Email)));
        return(Task.FromResult(data));
    }
Beispiel #12
0
        private Contact ExtractContact()
        {
            Contact contact = new Contact()
            {
                FormattedName      = FormattedName,
                Name1              = Prefix,
                Name2              = Surname,
                Name3              = GivenName,
                Name4              = MiddleName,
                NickName           = GivenName,
                Sortstring         = SortString,
                Birthday           = Birthday,
                Title              = Title,
                Organization       = Org,
                Note               = Note,
                EmailProgram       = Mailer,
                GlobalPositionning = Geocodage,
                LastRevision       = LastRevision,
                Logo               = Logo,
                Occupation         = Occupation,
                Photo              = Photo,
                Sound              = Sound,
                UniqueIdentifier   = UniqueIdentifier,
                Url       = Url,
                Category  = Category,
                TimeZone  = TimeZone,
                PublicKey = Key,
                Version   = Version,
            };

            if (Phones != null && Phones.Any())
            {
                contact.Phones = Phones.ToList();
            }
            if (Addresses != null && Addresses.Any())
            {
                contact.Addresses = Addresses.ToList();
            }
            if (Emails != null && Emails.Any())
            {
                contact.Mails = Emails.ToList();
            }
            contact.GeneratePhoto();
            return(contact);
        }
        public IEnumerable <ValidationResult> Validate(ValidationContext validationContext)
        {
            if (!Emails.Any())
            {
                yield return(new ValidationResult("An email is required."));
            }

            if (Emails.Count() > 20)
            {
                yield return(new ValidationResult("You can only invite up to 20 users at a time."));
            }

            var attr = new EmailAddressAttribute();

            for (int i = 0; i < Emails.Count(); i++)
            {
                if (!attr.IsValid(Emails.ElementAt(i)))
                {
                    yield return(new ValidationResult($"Email #{i + 1} is not valid.", new string[] { nameof(Emails) }));
                }
            }
        }