Ejemplo n.º 1
0
        public void RegisterUser(IUser user)
        {
            var freeNumber = PhoneNumbers.FirstOrDefault(x => x.Value.Equals(true)).Key;

            user.Terminal            = Station.TerminalService.GetFreeTerminal();
            user.Terminal.Number     = freeNumber;
            PhoneNumbers[freeNumber] = false;
            user.Tariff = Tariff;
            Users.Add(user);
        }
Ejemplo n.º 2
0
        public void RegisterUser(IUser user)
        {
            PhoneNumber freeNumber = PhoneNumbers.FirstOrDefault(x => x.Value.Equals(true)).Key;

            PhoneNumbers[freeNumber] = false;
            ITerminal terminal = new Terminal(freeNumber);
            IUser     user1    = new User(Station.GetTerminal().GetFreeTerminal(), Tarif);

            Users.Add(user);
        }
Ejemplo n.º 3
0
        public void RegisterUser(IUser user)
        {
            PhoneNumber freeNumber = PhoneNumbers.FirstOrDefault(x => x.Value.Equals(true)).Key;

            PhoneNumbers[freeNumber] = false;
            var terminal = Station.GetTerminal().GetFreeTerminal();

            terminal = new Terminal(freeNumber);
            user     = new User(user.GetGuid(), user.GetName(), user.GetMoney(), terminal, Tarif);

            Users.Add(user);
        }
Ejemplo n.º 4
0
        private bool CanEditNumber()
        {
            if (ErrorCollection.ContainsKey(nameof(EditablePhoneNumber)))
            {
                return(false);
            }

            if (string.IsNullOrWhiteSpace(editablePhoneNumber))
            {
                return(false);
            }

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

            if (PhoneNumbers.FirstOrDefault(phnm => phnm.PhoneNumber.Equals(editablePhoneNumber)) == null)
            {
                return(true);
            }

            return(false);
        }
Ejemplo n.º 5
0
        public void UpdateFrom(IContactInfo source, bool suppressIsChanged)
        {
            FirstName  = source.FirstName;
            MiddleName = source.MiddleName;
            LastName   = source.LastName;
            Company    = source.Company;
            JobTitle   = source.JobTitle;
            Note       = source.Note;
            Key        = source.Key;
            VersionKey = source.VersionKey == null ? String.Empty : source.VersionKey.ToString();

            // Phone numbers
            foreach (var item in source.PhoneNumbers)
            {
                var phoneNumber = PhoneNumbers.FirstOrDefault(x => x.Key == item.Key);
                if (phoneNumber != null)
                {
                    phoneNumber.UpdateFrom(item);
                }
                else
                {
                    PhoneNumbers.Add(new ContactPhoneLocal(item, AddressBook));
                }
            }
            foreach (var item in PhoneNumbers.Where(x => source.PhoneNumbers.All(y => x.Key != y.Key)).ToArray())
            {
                PhoneNumbers.Remove(item);
            }

            // Emails
            foreach (var item in source.Emails)
            {
                var email = Emails.FirstOrDefault(x => x.Key == item.Key);
                if (email != null)
                {
                    email.UpdateFrom(item);
                }
                else
                {
                    Emails.Add(new ContactEmailLocal(item, AddressBook));
                }
            }
            foreach (var item in Emails.Where(x => source.Emails.All(y => x.Key != y.Key)).ToArray())
            {
                Emails.Remove(item);
            }

            // Tags
            foreach (var item in source.Tags)
            {
                var tag = Tags.FirstOrDefault(x => x.Key == item.Key);
                if (tag != null)
                {
                    tag.UpdateFrom(item);
                }
                else
                {
                    var newTag = _contactsManager.Tags.FirstOrDefault(x => x.Key == item.Key);
                    if (newTag != null)
                    {
                        Tags.Add(newTag);
                    }
                }
            }
            foreach (var item in Tags.Where(x => source.Tags.All(y => x.Key != y.Key)).ToArray())
            {
                Tags.Remove(item);
            }

            if (suppressIsChanged)
            {
                IsChanged = false;
            }
        }