Exemplo n.º 1
0
        internal void WriteSubDivisionInfo(LomsContext db, SubDivision sub, out Zone zone, out Region region)
        {
            zone = null;
            region = null;

            if (sub.StateId != null)
            {
                State state = db.States.Include("Country").FirstOrDefault(s => s.Id == sub.StateId);
                if (state != null)
                    Write(", {0}", state.Acronym);

                if (state.Country != null)
                    WriteLine(", {0}", state.Country.Name);
            }

            if (sub.DivisionId != null)
            {
                Division division = db.Divisions.Include("Zone").Include("Zone.Region").FirstOrDefault(d => d.Id == sub.DivisionId);
                if (division != null && division.Zone != null)
                {
                    zone = division.Zone;
                    if (division.Zone.Region != null)
                    {
                        region = division.Zone.Region;
                        Write("{0} / ", region != null ? division.Zone.Region.Name : "");
                    }
                    Write("{0} / ", division.Zone != null ? division.Zone.Name : "");
                }
                WriteLine("{0} / {1}", division != null ? division.Name : "", sub.Name);

                //if (division != null && division.zoneId != ObjectId.Null)
                //{
                //    zone = AppDal.Zone.Get(transaction, division.zoneId);
                //    if (zone != null && zone.regionId != ObjectId.Null)
                //    {
                //        region = AppDal.Region.Get(transaction, zone.regionId);
                //        Write("{0} / ", region != null ? region.name : "");
                //    }
                //    Write("{0} / ", zone != null ? zone.name : "");
                //}
                //WriteLine("{0} / {1}", division != null ? division.name : "", sub.name);
            }
            else
                WriteLine(" /  /  / {0}", sub.Name);
        }
Exemplo n.º 2
0
        public bool Contains(Region region, Zone zone, Division division, SubDivision subDivision)
        {
            if (!RegionId.HasValue && !ZoneId.HasValue && !DivisionId.HasValue && !SubDivisionId.HasValue) //all regions
                return true;

            if (RegionId.HasValue && region != null && RegionId == region.Id)  //by region
                return true;

            if (ZoneId.HasValue && zone != null && ZoneId == zone.Id)  //by zone
                return true;

            if (DivisionId.HasValue && division != null && DivisionId == division.Id)  //by division
                return true;

            if (SubDivisionId.HasValue && subDivision != null && SubDivisionId == subDivision.Id)  //by division
                return true;

            return false;
        }
Exemplo n.º 3
0
     private void FixupSubDivision(SubDivision previousValue, bool skipKeys = false)
     {
         if (IsDeserializing)
         {
             return;
         }
 
         if (previousValue != null && previousValue.EventAreas.Contains(this))
         {
             previousValue.EventAreas.Remove(this);
         }
 
         if (SubDivision != null)
         {
             if (!SubDivision.EventAreas.Contains(this))
             {
                 SubDivision.EventAreas.Add(this);
             }
 
             SubDivisionId = SubDivision.Id;
         }
         else if (!skipKeys)
         {
             SubDivisionId = null;
         }
 
         if (ChangeTracker.ChangeTrackingEnabled)
         {
             if (ChangeTracker.OriginalValues.ContainsKey("SubDivision")
                 && (ChangeTracker.OriginalValues["SubDivision"] == SubDivision))
             {
                 ChangeTracker.OriginalValues.Remove("SubDivision");
             }
             else
             {
                 ChangeTracker.RecordOriginalValue("SubDivision", previousValue);
             }
             if (SubDivision != null && !SubDivision.ChangeTracker.ChangeTrackingEnabled)
             {
                 SubDivision.StartTracking();
             }
         }
     }
Exemplo n.º 4
0
     public bool Equals(SubDivision other)
     {
         if (ReferenceEquals(null, other)) return false;
         if (ReferenceEquals(this, other)) return true;
 		if (other.Id == 0 && Id == 0)
 			return false;
 		else
 			return other.Id == Id;
     }