예제 #1
0
        public virtual void Update(Dealer dealer, DealerType dealerType, Region region, City city, Town town, bool updateStatus)
        {
            Address    = dealer.Address;
            PostalCode = dealer.PostalCode;
            Region     = region;
            City       = city;
            Town       = town;
            DealerType = dealerType;
            Longitude  = dealer.Longitude;
            Latitude   = dealer.Latitude;

            dealer.DealerLocalization
            .ToList()
            .ForEach(dealerLocalization =>
            {
                if (DealerLocalization.ContainsKey(dealerLocalization.Key))
                {
                    DealerLocalization[dealerLocalization.Key].Update(dealerLocalization.Value.ToString());
                }
                else
                {
                    DealerLocalization.Add(dealerLocalization.Key, new DealerLocalization(dealerLocalization.Value.ToString()));
                }
            });

            if (dealer.DealerEmailAddresses != null)
            {
                foreach (var dealerEmailAddress in dealer.DealerEmailAddresses)
                {
                    DealerEmailAddresses.Add(new DealerEmailAddress(this, dealerEmailAddress.IsDefault, dealerEmailAddress.EmailAddress));
                }

                DealerEmailAddresses.ToList()
                .ForEach(dealerEmailAddress =>
                {
                    if (!dealer.DealerEmailAddresses.Select(x => x.EmailAddress).Contains(dealerEmailAddress.EmailAddress))
                    {
                        DealerEmailAddresses.Remove(dealerEmailAddress);
                    }
                });
            }

            if (dealer.DealerPhoneNumbers != null)
            {
                foreach (var dealerPhoneNumber in dealer.DealerPhoneNumbers)
                {
                    DealerPhoneNumbers.Add(new DealerPhoneNumber(this, dealerPhoneNumber.IsDefault, dealerPhoneNumber.PhoneNumber));
                }

                DealerPhoneNumbers.ToList()
                .ForEach(dealerPhoneNumber =>
                {
                    if (!dealer.DealerPhoneNumbers.Select(x => x.PhoneNumber).Contains(dealerPhoneNumber.PhoneNumber))
                    {
                        DealerPhoneNumbers.Remove(dealerPhoneNumber);
                    }
                });
            }

            if (updateStatus)
            {
                SetStatus(dealer.Status);
            }
        }
예제 #2
0
        public Dealer(Dealer dealer, Institution institution, Region region, City city, Town town, DealerType dealerType) : this()
        {
            Institution = institution;
            DealerCode  = dealer.DealerCode;
            DealerType  = dealerType;
            Status      = dealer.Status;
            Address     = dealer.Address;
            PostalCode  = dealer.PostalCode;
            Region      = region;
            City        = city;
            Town        = town;
            Longitude   = dealer.Longitude;
            Latitude    = dealer.Latitude;

            if (dealer.DealerEmailAddresses != null)
            {
                foreach (var dealerEmailAddressDTO in dealer.DealerEmailAddresses)
                {
                    DealerEmailAddresses.Add(new DealerEmailAddress(this, dealerEmailAddressDTO.IsDefault, dealerEmailAddressDTO.EmailAddress));
                }
            }

            if (dealer.DealerPhoneNumbers != null)
            {
                foreach (var dealerPhoneNumberDTO in dealer.DealerPhoneNumbers)
                {
                    DealerPhoneNumbers.Add(new DealerPhoneNumber(this, dealerPhoneNumberDTO.IsDefault, dealerPhoneNumberDTO.PhoneNumber));
                }
            }

            dealer.DealerLocalization
            .ToList()
            .ForEach(dealerLocalization => DealerLocalization.Add(dealerLocalization.Key, new DealerLocalization(dealerLocalization.Value.ToString())));
        }