Ejemplo n.º 1
0
 private void ClearHomeAddress_Click(object sender, RoutedEventArgs e)
 {
     var previousAddress = ViewModel.HomeAddressViewModel.Address;
     var newAddress = new AssociationUserAddress { Nickname = "x", Id = previousAddress.Id, Country = previousAddress.Country };
     newAddress.AcceptChanges();
     ViewModel.HomeAddressViewModel.Address = newAddress;
 }
Ejemplo n.º 2
0
        public AssociationUser CreateNewManagedUser()
        {
            var profile = new AssociationUser
            {
                ManagerId = this.Id,
                CreatedById = this.Id,
                CreatedBy = this.FullName,
                Country = this.Country,
            };
            if (this.IsTravelAgency)
                profile.CreatedBy += " " + this.TravelAgencyName;

            var homeAddress = new AssociationUserAddress { Country = this.Country, Nickname = "x" };
            var workAddress = new AssociationUserAddress { Country = this.Country, Nickname = "y" };
            homeAddress.AcceptChanges();
            workAddress.AcceptChanges();

            return profile;
        }
Ejemplo n.º 3
0
        public AssociationUserAddress SaveAddress(AssociationUserAddress address)
        {
            if (address.Suburb != null)
            {
                address.Country = null;
                address.State = null;
            }
            else if (address.State != null)
                address.Country = null;

            using (var db = new LomsContext())
            {
                db.AssociationUserAddresses.ApplyChanges(address);
                db.SaveChanges();

                address = db.AssociationUserAddresses.IncludeAll("Country", "State", "State.Country", "Suburb", "Suburb.Country", "Suburb.State", "Suburb.State.Country")
                    .FirstOrDefault(a => a.Id == address.Id);
                address.AcceptChanges();

                return address;
            }
        }