示例#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);
        }
示例#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;
        }
示例#3
0
        private static List<AdminFee> GetAdminFees(LomsContext db, Booking booking, Zone zoneFrom, Region regionFrom, Zone zoneTo, Region regionTo)
        {
            var date = (from d in db.AdminFeeDates
                        where d.CountryId == booking.City.CountryId && d.StartDate <= booking.PickUpTime
                        orderby d.StartDate descending
                        select d)
                        .Take(1).FirstOrDefault();

            if (date == null)
                return null;

            var fees = new List<AdminFee>();

            var regionFees = from f in db.RegionAdminFeeValues
                             where
                             f.DateId == date.Id
                             &&
                             (
                                 f.FromId == regionFrom.Id && f.ToId == regionTo.Id ||
                                 f.FromId.HasValue && f.ToId == regionTo.Id ||
                                 f.FromId == regionFrom.Id && !f.ToId.HasValue
                             )
                             select f;
            regionFees.ForEach(rf => fees.Add(new AdminFee(rf.Margin, rf.Fee)));


            var zoneFees = from f in db.ZoneAdminFeeValues
                           where
                           f.DateId == date.Id
                           &&
                           (
                               f.FromId == regionFrom.Id && f.ToId == regionTo.Id ||
                               f.FromId == null && f.ToId == regionTo.Id ||
                               f.FromId == regionFrom.Id && f.ToId == null
                             )
                           select f;
            zoneFees.ForEach(zf => fees.Add(new AdminFee(zf.Margin, zf.Fee)));

            return fees;
        }
示例#4
0
     private void FixupZone(Zone previousValue, bool skipKeys = false)
     {
         if (IsDeserializing)
         {
             return;
         }
 
         if (previousValue != null && previousValue.EventAreas.Contains(this))
         {
             previousValue.EventAreas.Remove(this);
         }
 
         if (Zone != null)
         {
             if (!Zone.EventAreas.Contains(this))
             {
                 Zone.EventAreas.Add(this);
             }
 
             ZoneId = Zone.Id;
         }
         else if (!skipKeys)
         {
             ZoneId = null;
         }
 
         if (ChangeTracker.ChangeTrackingEnabled)
         {
             if (ChangeTracker.OriginalValues.ContainsKey("Zone")
                 && (ChangeTracker.OriginalValues["Zone"] == Zone))
             {
                 ChangeTracker.OriginalValues.Remove("Zone");
             }
             else
             {
                 ChangeTracker.RecordOriginalValue("Zone", previousValue);
             }
             if (Zone != null && !Zone.ChangeTracker.ChangeTrackingEnabled)
             {
                 Zone.StartTracking();
             }
         }
     }
示例#5
0
文件: Zone.cs 项目: felixthehat/Limo
     public bool Equals(Zone 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;
     }
示例#6
0
     private void FixupZone1(Zone previousValue, bool skipKeys = false)
     {
         if (IsDeserializing)
         {
             return;
         }
 
         if (previousValue != null && previousValue.ZoneAdminFeeValues1.Contains(this))
         {
             previousValue.ZoneAdminFeeValues1.Remove(this);
         }
 
         if (Zone1 != null)
         {
             if (!Zone1.ZoneAdminFeeValues1.Contains(this))
             {
                 Zone1.ZoneAdminFeeValues1.Add(this);
             }
 
             ToId = Zone1.Id;
         }
         else if (!skipKeys)
         {
             ToId = null;
         }
 
         if (ChangeTracker.ChangeTrackingEnabled)
         {
             if (ChangeTracker.OriginalValues.ContainsKey("Zone1")
                 && (ChangeTracker.OriginalValues["Zone1"] == Zone1))
             {
                 ChangeTracker.OriginalValues.Remove("Zone1");
             }
             else
             {
                 ChangeTracker.RecordOriginalValue("Zone1", previousValue);
             }
             if (Zone1 != null && !Zone1.ChangeTracker.ChangeTrackingEnabled)
             {
                 Zone1.StartTracking();
             }
         }
     }