private string GenerateName(Entities.ConstraintTourDate date) { return(string.Format("Tour date: [{0}/{1}/{2}] to [{3}/{4}/{5}]", date.StartDate.Year == -1 ? "Year" : date.StartDate.Year.ToString(), date.StartDate.Month == -1 ? "Month" : date.StartDate.Month.ToString(), date.StartDate.Day == -1 ? "Day" : date.StartDate.Day.ToString(), date.EndDate.Year == -1 ? "Year" : date.EndDate.Year.ToString(), date.EndDate.Month == -1 ? "Month" : date.EndDate.Month.ToString(), date.EndDate.Day == -1 ? "Day" : date.EndDate.Day.ToString() )); }
public bool GetProperties(object displayObject, Entities.TourCostRuleConstraint con) { Entities.ConstraintTourDate date = (Entities.ConstraintTourDate)displayObject; con.Properties.Clear(); Entities.TourCostRuleConstraintProperty property; property = new Entities.TourCostRuleConstraintProperty(); property.TypeId = (int)TypeIds.StartYear; property.Value = date.StartDate.Year; con.Properties.Add(property); property = new Entities.TourCostRuleConstraintProperty(); property.TypeId = (int)TypeIds.StartMonth; property.Value = date.StartDate.Month; con.Properties.Add(property); property = new Entities.TourCostRuleConstraintProperty(); property.TypeId = (int)TypeIds.StartDay; property.Value = date.StartDate.Day; con.Properties.Add(property); property = new Entities.TourCostRuleConstraintProperty(); property.TypeId = (int)TypeIds.EndYear; property.Value = date.EndDate.Year; con.Properties.Add(property); property = new Entities.TourCostRuleConstraintProperty(); property.TypeId = (int)TypeIds.EndMonth; property.Value = date.EndDate.Month; con.Properties.Add(property); property = new Entities.TourCostRuleConstraintProperty(); property.TypeId = (int)TypeIds.EndDay; property.Value = date.EndDate.Day; con.Properties.Add(property); con.Name = GenerateName(date); return(true); return(false); }
public object GetDisplayObject(Entities.TourCostRuleConstraintPropertyCollection properties) { Entities.ConstraintTourDate date = new Entities.ConstraintTourDate(); foreach (Entities.TourCostRuleConstraintProperty property in properties) { TypeIds type = (TypeIds)property.TypeId; switch (type) { case TypeIds.StartYear: date.StartDate.Year = (int)property.Value; break; case TypeIds.StartMonth: date.StartDate.Month = (int)property.Value; break; case TypeIds.StartDay: date.StartDate.Day = (int)property.Value; break; case TypeIds.EndYear: date.EndDate.Year = (int)property.Value; break; case TypeIds.EndMonth: date.EndDate.Month = (int)property.Value; break; case TypeIds.EndDay: date.EndDate.Day = (int)property.Value; break; } } return(date); }
public bool Matches(Entities.Tour tour, ITourService service, Entities.TourCostDetail detail, Entities.TourCostRuleConstraint constraint) { bool res = false; Entities.ConstraintTourDate date = (Entities.ConstraintTourDate) this.mapper.GetDisplayObject(constraint.Properties); if (date != null) { if (date.StartDate.Year >= 0) { if (tour.Time.Date.Year < date.StartDate.Year) { // Hour value of tour is // less than min of the rule return(res); } else if (tour.Time.Date.Year == date.StartDate.Year) { if (date.StartDate.Month >= 0) { if (date.StartDate.Month > tour.Time.Date.Month) { return(res); } else if (date.StartDate.Month == tour.Time.Date.Month) { if (date.StartDate.Day >= 0 && date.StartDate.Day > tour.Time.Date.Day) { return(res); } }/* * else if (date.StartDate.Day >= 0 && * date.StartDate.Day > tour.Time.Date.Day) * { * return res; * }*/ } else if (date.StartDate.Day >= 0 && date.StartDate.Day > tour.Time.Date.Day) { return(res); } } } else if (date.StartDate.Month >= 0) { if (date.StartDate.Month > tour.Time.Date.Month) { return(res); } else if (date.StartDate.Month == tour.Time.Date.Month) { if (date.StartDate.Day >= 0 && date.StartDate.Day > tour.Time.Date.Day) { return(res); } } } else if (date.StartDate.Day >= 0 && date.StartDate.Day > tour.Time.Date.Day) { return(res); } if (date.EndDate.Year >= 0) { if (tour.Time.Date.Year > date.EndDate.Year) { return(res); } else if (tour.Time.Date.Year == date.EndDate.Year) { if (date.EndDate.Month >= 0) { if (date.EndDate.Month < tour.Time.Date.Month) { return(res); } else if (date.EndDate.Month == tour.Time.Date.Month) { if (date.EndDate.Day >= 0 && date.EndDate.Day < tour.Time.Date.Day) { return(res); } } } else if (date.EndDate.Day >= 0 && date.EndDate.Day < tour.Time.Date.Day) { return(res); } } } else if (date.EndDate.Month >= 0) { if (date.EndDate.Month < tour.Time.Date.Month) { return(res); } else if (date.EndDate.Month == tour.Time.Date.Month) { if (date.EndDate.Day >= 0 && date.EndDate.Day < tour.Time.Date.Day) { return(res); } } } else if (date.EndDate.Day >= 0 && date.EndDate.Day < tour.Time.Date.Day) { return(res); } res = true; } return(res); }