/// <summary>
        /// Создание места для модификации заполняя недостающие данные из старого объекта,
        /// Если не один из типов мест не указан для модификации, то возвращается null
        /// </summary>
        /// <returns>Созданный объект</returns>
        public PreferedPlace CreatePlaceForModify()
        {
            PreferedPlace res = null;

            if (NewNotSpecificPlace != null)
            {
                res = new PreferedPlace();
                res.SmokingAllowed = NewNotSpecificPlace.SmokingAllowed;
                res.Location       = NewNotSpecificPlace.Location;
            }

            if (NewSpecificPlace != null)
            {
                if (res == null)
                {
                    res = new PreferedPlace();
                }
                res.PlaceNumber = NewSpecificPlace.PlaceNumber;
                res.RowNumber   = NewSpecificPlace.RowNumber;
            }

            if (res != null)
            {
                res.SegNumber = SegNum;
            }

            return(res);
        }
Beispiel #2
0
        /// <summary>
        /// Создание информации о пассажире для модификации
        /// </summary>
        /// <param name="oldInfo">Старая информация о пассажире</param>
        /// <returns>Новая информация о пассажире</returns>
        public Traveller CreateTravellerForModify(BookedTraveller oldInfo)
        {
            Traveller res = new Traveller();

            res.Type = oldInfo.Type;
            res.Num  = oldInfo.Num;

            if (ArrAddress != null)
            {
                res.ArrAddress = ArrAddress;
            }

            if (ContactInfo != null)
            {
                res.ContactInfo = ContactInfo.CreateContactForModify(oldInfo.ContactInfo);
            }

            if (DocumentInfo != null)
            {
                res.DocumentInfo = DocumentInfo;
            }

            if (Meal.HasValue)
            {
                res.Meal = Meal.ToString();
            }

            if (PersonalInfo != null)
            {
                res.PersonalInfo = PersonalInfo.CreateTravellerForModify(oldInfo.PersonalInfo);
            }

            if (PreferedPlaces != null && PreferedPlaces.Count > 0)
            {
                res.PreferedPlaces = new List <PreferedPlace>();

                foreach (var place in PreferedPlaces)
                {
                    PreferedPlace newPlace = place.CreatePlaceForModify();

                    if (newPlace != null)
                    {
                        res.PreferedPlaces.Add(newPlace);
                    }
                }
            }

            if (VisaInfo != null)
            {
                res.VisaInfo = VisaInfo;
            }

            return(res);
        }
Beispiel #3
0
        /// <summary>
        /// Выполняет модификацию хранимой информации о предпочитаемых местах пассажира
        /// </summary>
        /// <param name="placeInfo">Новая информация о предпочитаемых местах</param>
        /// <param name="specificPlaceModified">Ассоциативный массив индикаторов какие из мест были модифицированы</param>
        public void ModifyPlaceInfo(List <TravellerPreferedPlace> placeInfo, Dictionary <int, bool> specificPlaceModified)
        {
            PreferedPlace tmpPlace, oldPlaceInfo;

            if (placeInfo != null && placeInfo.Count > 0)
            {
                foreach (TravellerPreferedPlace newPlaceInfo in placeInfo)
                {
                    if (PreferedPlaces == null)
                    {
                        PreferedPlaces = new List <PreferedPlace>();
                    }

                    //находим старую информацию о предпочитаемом месте
                    oldPlaceInfo = PreferedPlaces.Find(place => place.SegNumber == newPlaceInfo.SegNum);

                    //если есть новая информация о неконкретном (не через карту мест) предпочитаемом месте
                    if (newPlaceInfo.NewNotSpecificPlace != null)
                    {
                        if (oldPlaceInfo != null)
                        {
                            oldPlaceInfo.SmokingAllowed = newPlaceInfo.NewNotSpecificPlace.SmokingAllowed;
                            oldPlaceInfo.Location       = newPlaceInfo.NewNotSpecificPlace.Location;
                        }
                        else
                        {
                            tmpPlace = new PreferedPlace();
                            tmpPlace.SmokingAllowed = newPlaceInfo.NewNotSpecificPlace.SmokingAllowed;
                            tmpPlace.Location       = newPlaceInfo.NewNotSpecificPlace.Location;
                            PreferedPlaces.Add(tmpPlace);
                        }
                    }

                    //если есть новая информация о конкретном месте и оно было модифицировано
                    if (newPlaceInfo.NewSpecificPlace != null && specificPlaceModified[newPlaceInfo.SegNum])
                    {
                        if (oldPlaceInfo != null)
                        {
                            oldPlaceInfo.PlaceNumber = newPlaceInfo.NewSpecificPlace.PlaceNumber;
                            oldPlaceInfo.RowNumber   = newPlaceInfo.NewSpecificPlace.RowNumber;
                        }
                        else
                        {
                            tmpPlace             = new PreferedPlace();
                            tmpPlace.PlaceNumber = newPlaceInfo.NewSpecificPlace.PlaceNumber;
                            tmpPlace.RowNumber   = newPlaceInfo.NewSpecificPlace.RowNumber;
                            PreferedPlaces.Add(tmpPlace);
                        }
                    }
                }
            }
        }