/// <summary> /// 保存航班最低价 /// </summary> /// <param name="departure">出发地</param> /// <param name="arrival">到达地</param> /// <param name="flightDate">航班日期</param> /// <param name="fare">价格</param> /// <param name="discount">折扣</param> /// <param name="product">产品类型</param> public static void SaveFlightLowerFare(string departure, string arrival, DateTime flightDate, decimal fare, decimal discount, ProductType product) { if (string.IsNullOrWhiteSpace(departure)) { throw new ArgumentNullException("departure"); } if (string.IsNullOrWhiteSpace(arrival)) { throw new ArgumentNullException("arrival"); } if (fare <= 0) { throw new InvalidOperationException("fare"); } if (discount <= 0) { throw new InvalidOperationException("discount"); } var model = new Recommend.Domain.FareInfo(departure, arrival, flightDate, fare, discount, product); Recommend.Domain.FareDataCenter.Instance.Save(model); }
public void Save(FareInfo item) { if (item == null) { throw new ArgumentNullException("item"); } if (item.FlightDate.Date >= DateTime.Today) { var key = getKey(item.Departure, item.Arrival, item.FlightDate); FareInfo obj; lock (m_locker) { if (m_fares.TryGetValue(key, out obj)) { obj.Update(item.Fare, item.Discount, item.Product); } else { m_fares.Add(key, item); } } } }