Exemple #1
0
 /// <summary>
 ///     更新飞机证照集合
 /// </summary>
 /// <param name="sourceAircraftLicenses">客户端集合</param>
 /// <param name="dstAircraft">数据库集合</param>
 private void UpdateAircraftLicenses(IEnumerable<AircraftLicenseDTO> sourceAircraftLicenses, Aircraft dstAircraft)
 {
     var aircraftLicense = new List<AircraftLicense>();
     foreach (AircraftLicenseDTO sourceAircraftLicense in sourceAircraftLicenses)
     {
         AircraftLicense result =
             dstAircraft.Licenses.FirstOrDefault(p => p.Id == sourceAircraftLicense.AircraftLicenseId);
         if (result == null)
         {
             result = AircraftLicenseFactory.CreateAircraftLicense();
             result.ChangeCurrentIdentity(sourceAircraftLicense.AircraftLicenseId);
         }
         AircraftLicenseFactory.SetAircraftLicense(result, sourceAircraftLicense.Name,
             sourceAircraftLicense.LicenseTypeId, sourceAircraftLicense.Description,
             sourceAircraftLicense.IssuedUnit,
             sourceAircraftLicense.IssuedDate, sourceAircraftLicense.ValidMonths,
             sourceAircraftLicense.ExpireDate, sourceAircraftLicense.State, sourceAircraftLicense.FileName,
             sourceAircraftLicense.FileContent);
         aircraftLicense.Add(result);
     }
     dstAircraft.Licenses.ToList().ForEach(p =>
     {
         if (aircraftLicense.FirstOrDefault(t => t.Id == p.Id) == null)
         {
             _aircraftRepository.RemoveAircraftLicense(p);
         }
     });
     dstAircraft.Licenses = aircraftLicense;
 }
Exemple #2
0
        /// <summary>
        ///     创建新飞机
        /// </summary>
        /// <param name="regNumber">飞机注册号</param>
        /// <param name="serialNumber"></param>
        /// <param name="aircraftTypeId">机型ID</param>
        /// <param name="actionCategoryId">业务活动类型</param>
        /// <param name="airlinesId">航空公司ID</param>
        /// <returns>飞机</returns>
        public static Aircraft CreateAircraft(string regNumber, string serialNumber,
            Guid airlinesId, Guid aircraftTypeId, Guid actionCategoryId)
        {
            if (string.IsNullOrWhiteSpace(regNumber))
            {
                throw new ArgumentException("注册号参数为空!");
            }
            if (string.IsNullOrWhiteSpace(serialNumber))
            {
                throw new ArgumentException("序列号参数为空!");
            }

            var aircraft = new Aircraft
            {
                RegNumber = regNumber,
                SerialNumber = serialNumber,
                AirlinesId = airlinesId,
                AircraftTypeId = aircraftTypeId,
                ImportCategoryId = actionCategoryId,
                CreateDate = DateTime.Now
            };
            aircraft.GenerateNewIdentity();

            return aircraft;
        }