示例#1
0
        /// <summary>
        /// Get location data and try to add location ids to ship
        /// If any location id was used with previous ship then return false
        /// </summary>
        /// <param name="locationModel"><see cref="LocationModel"/></param>
        /// <param name="shipModel"><see cref="ShipModel"/></param>
        /// <returns></returns>
        public bool TryToGenerateShipModel(LocationModel locationModel,
                                           ref ShipModel shipModel)
        {
            var horizontalIndexName = locationModel.StartHorizontalPositionIndex.GetHorizontalIndexName();

            foreach (var locationId in GetLocationIdsPositions(locationModel))
            {
                shipModel.AddLocation(locationId);

                if (_usedLocationsIds.Any(u => u.ToLower() == locationId.ToLower()))
                {
                    shipModel.ClearLocationIds();
                    return(false);
                }
            }

            shipModel.LocationIds.ForEach(locationId => _usedLocationsIds.Add(locationId));

            return(true);
        }