예제 #1
0
        private void Save()
        {
            if (string.IsNullOrWhiteSpace(Garage.Number))
            {
                MessageBox.Show("Необходимо указать номер гаража");
                return;
            }

            if (DBManager.IsSameGarageExists(Garage))
            {
                MessageBox.Show("Гараж с таким номером уже существует");
                return;
            }

            DBManager.SaveGarage(Garage);

            foreach (var phone in Phones)
            {
                phone.GarageID = Garage.ID;
            }

            DBManager.SaveGaragePhones(Garage.ID, Phones);
            Garage.Phones = Phones.ToList();

            GarageSaved?.Invoke(Garage);
            _view.DialogResult = true;
        }
예제 #2
0
        public void AddPhone(Phone phone)
        {
            var list = Phones.ToList();

            if (!list.Any(o => o.Equals(phone)))
            {
                list.Add(phone);
            }
            else
            {
                throw Validator.ErrorValidation(("Phone", "Was Exists"));
            }

            Phones = list;
        }
예제 #3
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);
        }