Пример #1
0
 /// <summary>
 ///     移除所有权历史
 /// </summary>
 /// <param name="ownership">
 ///     <see cref="IFleetPlanService" />
 /// </param>
 public void RemoveOwnership(OwnershipHistoryDTO ownership)
 {
     using (var pb = new FleetPlanServiceHelper())
     {
         pb.RemoveOwnership(ownership, this);
     }
 }
Пример #2
0
 /// <summary>
 /// 移除所有权历史记录
 /// </summary>
 /// <param name="ownership"></param>
 /// <param name="service"></param>
 internal void RemoveOwnership(OwnershipHistoryDTO ownership, IFleetPlanService service)
 {
     //var ownweships =
     //    service.EntityContainer.GetEntitySet<OwnershipHistory>()
     //           .Where(os => os.Aircraft == ownership.Aircraft)
     //           .OrderBy(os => os.StartDate)
     //           .ToList();
     //var count = ownweships.Count;
     //// 所有权历史至少要保留一条
     //if (count > 1)
     //{
     //    service.EntityContainer.GetEntitySet<OwnershipHistory>().Remove(ownership);
     //    // 修改之前记录的结束日期
     //    ownweships[count - 2].EndDate = null;
     //}
 }
Пример #3
0
        /// <summary>
        ///     执行新增命令。
        /// </summary>
        /// <param name="sender"></param>
        public void OnAddOwnership(object sender)
        {
            StartDisplayDate =
                SelectedAircraft.OwnershipHistories.Select(p => p.StartDate).OrderBy(p => p).LastOrDefault();
            //新建所有权历史
            SelectedOwnershipHistory = new OwnershipHistoryDTO
            {
                OwnershipHistoryId = Guid.NewGuid(),
                StartDate =
                    (StartDisplayDate == null || StartDisplayDate.Value == DateTime.MinValue)
                        ? DateTime.Now
                        : StartDisplayDate.Value.AddDays(1)
            };

            SelectedAircraft.OwnershipHistories.Add(SelectedOwnershipHistory);
            RefreshCommandState();
        }