private static ConnectionDTO MappConnection2ConnectionDTO(Connection con)
        {
            ConnectionDTO conDTO = new ConnectionDTO()
            {
                EndPlace   = con.EndPlace,
                Id         = con.Id,
                Version    = con.Version,
                Name       = con.Name,
                StartPlace = con.StartPlace,
                Train      = Mapper.Map <Train, TrainDTO>(con.Train),
                Parts      = new List <ConnectionPartDTO>()
            };

            foreach (var part in con.Parts)
            {
                ConnectionPartDTO conpart = new ConnectionPartDTO()
                {
                    EndTime   = part.EndTime,
                    FreeSeats = part.FreeSeats,
                    Id        = part.Id,
                    Seats     = part.Seats,
                    StartTime = part.StartTime,
                    Version   = part.Version,
                    Route     = Mapper.Map <Route, RouteDTO>(part.Route),
                };
                conpart.Connection = conDTO;
                conDTO.Parts.Add(conpart);
            }
            return(conDTO);
        }
        private static ConnectionPart MappConnectionPartDTO2ConnectionPart(ConnectionPartDTO conPartDTO)
        {
            ConnectionPart conPart = new ConnectionPart()
            {
                EndTime   = conPartDTO.EndTime,
                FreeSeats = conPartDTO.FreeSeats,
                Id        = conPartDTO.Id,
                Seats     = conPartDTO.Seats,
                StartTime = conPartDTO.StartTime,
                Version   = conPartDTO.Version,
                Route     = Mapper.Map <RouteDTO, Route>(conPartDTO.Route),
            };

            conPart.Connection = new Connection()
            {
                EndPlace   = conPartDTO.Connection.EndPlace,
                Id         = conPartDTO.Connection.Id,
                Version    = conPartDTO.Connection.Version,
                Name       = conPartDTO.Connection.Name,
                StartPlace = conPartDTO.Connection.StartPlace,
                Train      = Mapper.Map <TrainDTO, Train>(conPartDTO.Connection.Train),
            };

            conPart.Connection.Parts = new List <ConnectionPart>();

            foreach (var part in conPartDTO.Connection.Parts)
            {
                if (part.Id == conPart.Id)
                {
                    conPart.Connection.Parts.Add(conPart);
                }
                else
                {
                    ConnectionPart conpart = new ConnectionPart()
                    {
                        EndTime   = part.EndTime,
                        FreeSeats = part.FreeSeats,
                        Id        = part.Id,
                        Seats     = part.Seats,
                        StartTime = part.StartTime,
                        Version   = part.Version,
                        Route     = Mapper.Map <RouteDTO, Route>(part.Route),
                    };
                    conpart.Connection = conPart.Connection;
                    conPart.Connection.Parts.Add(conpart);
                }
            }

            return(conPart);
        }