예제 #1
0
        public override PlaceChangeRequest GetInstance(ISession session, ManagedSecurityContext sec)
        {
            PlaceChangeRequest instance = base.GetInstance(session, sec);

            instance.Name        = this.Name;
            instance.Type        = ManagedPlaceType.Find(session, this.Type);
            instance.Description = this.Description;
            instance.Street      = this.Street;
            instance.Zip         = this.Zip;
            instance.CrossStreet = this.CrossStreet;
            instance.Phone       = this.Phone;
            instance.Fax         = this.Fax;
            instance.Email       = this.Email;
            if (Id == 0)
            {
                instance.Account = GetOwner(session, AccountId, sec);
            }
            instance.City = (!string.IsNullOrEmpty(City))
                ? ManagedCity.FindOrCreate(session, City, State, Country)
                : null;
            instance.Neighborhood = (!string.IsNullOrEmpty(Neighborhood) && !string.IsNullOrEmpty(City))
                ? ManagedNeighborhood.FindOrCreate(session, Neighborhood, City, State, Country)
                : null;
            if (Id == 0)
            {
                instance.Place = session.Load <Place>(PlaceId);
            }
            return(instance);
        }
예제 #2
0
        public static Neighborhood Find(ISession session, string name, string city, string state, string country)
        {
            if (string.IsNullOrEmpty(country))
            {
                throw new ManagedCountry.InvalidCountryException();
            }

            if (string.IsNullOrEmpty(city))
            {
                throw new ManagedCity.InvalidCityException();
            }

            City c = ManagedCity.Find(session, city, state, country);

            Neighborhood neighborhood = (Neighborhood)session.CreateCriteria(typeof(Neighborhood))
                                        .Add(Expression.Eq("Name", name))
                                        .Add(Expression.Eq("City.Id", c.Id))
                                        .UniqueResult();

            if (neighborhood == null)
            {
                throw new InvalidNeighborhoodException();
            }

            return(neighborhood);
        }
예제 #3
0
        public override Neighborhood GetInstance(ISession session, ManagedSecurityContext sec)
        {
            Neighborhood instance = base.GetInstance(session, sec);

            instance.Name = this.Name;
            if (!string.IsNullOrEmpty(City))
            {
                instance.City = ManagedCity.Find(session, City, State, Country);
            }
            return(instance);
        }
예제 #4
0
 public static Neighborhood FindOrCreate(ISession session, string name, string city, string state, string country)
 {
     try
     {
         return(Find(session, name, city, state, country));
     }
     catch (InvalidNeighborhoodException)
     {
         Neighborhood neighborhood = new Neighborhood();
         neighborhood.City = ManagedCity.Find(session, city, state, country);
         neighborhood.Name = name;
         session.Save(neighborhood);
         return(neighborhood);
     }
 }
예제 #5
0
        public override TransitAccountCity GetTransitInstance(ManagedSecurityContext sec)
        {
            TransitAccountCity t_instance = base.GetTransitInstance(sec);

            if (mInstance.Country_Id != 0)
            {
                t_instance.Country = Session.Load <Country>(mInstance.Country_Id).Name;
            }
            if (mInstance.State_Id != 0)
            {
                t_instance.State = Session.Load <State>(mInstance.State_Id).Name;
            }
            int city_id = 0;

            if (ManagedCity.TryGetCityId(Session, mInstance.City, t_instance.State, t_instance.Country, out city_id))
            {
                t_instance.Id = city_id;
            }
            return(t_instance);
        }