public List<DestinationPhotosModel> CreatePhotoList(DestinationObjectLayer destination)
 {
     List<DestinationPhotosModel> photoList = new List<DestinationPhotosModel>();
     foreach (DestinationPhotos photo in destination.DestinationPhotos)
     {
         DestinationPhotosModel photoForList = new DestinationPhotosModel(photo.id, photo.destinationLayerId, photo.imagePath);
         photoList.Add(photoForList);
     }
     return photoList;
 }
 public List<DestinationMenuModel> CreateMenu(DestinationObjectLayer destination)
 {
     List<DestinationMenuModel> menuList = new List<DestinationMenuModel>();
     foreach (DestinationMenu menuItem in destination.DestinationMenu)
     {
         DestinationMenuModel menuForList = new DestinationMenuModel(menuItem.id, menuItem.destinationLayerId, menuItem.menu);
         menuList.Add(menuForList);
     }
     return menuList;
 }
 public List<DestinationEnterExitsModel> CreateEnterExitsList(DestinationObjectLayer destination)
 {
     List<DestinationEnterExitsModel> enterExitsList = new List<DestinationEnterExitsModel>();
     foreach (DestinationEnterExits enterExit in destination.DestinationEnterExits)
     {
         DestinationEnterExitsModel enterExitForList = new DestinationEnterExitsModel(enterExit.id, enterExit.destinationLayerId, enterExit.typeId, enterExit.latitude, enterExit.longitude, enterExit.hadicapAccessible);
         enterExitsList.Add(enterExitForList);
     }
     return enterExitsList;
 }
 public List<DestinationAdditionalFeesModel> CreateAdditionalFees(DestinationObjectLayer destination)
 {
     List<DestinationAdditionalFeesModel> feesList = new List<DestinationAdditionalFeesModel>();
     foreach (DestinationAdditionalFees fee in destination.DestinationAdditionalFees)
     {
         DestinationAdditionalFeesModel feeForList = new DestinationAdditionalFeesModel(fee.additionalFeesId, fee.destinationLayerId, fee.fee, fee.feeName);
         feesList.Add(feeForList);
     }
     return feesList;
 }
        public DestinationModel createDestination(DestinationObjectLayer destination)
        {
            DestinationModel newDestination = null;

            if (destination.MapPoint.MapPointType.type == "Exhibits" || destination.MapPoint.MapPointType.type == "Zoo360" )
            {
                List<DestinationPhotosModel> photoList = _DestinationRepository.CreatePhotoList(destination);
                List<DestinationEnterExitsModel> enterExitsList = _DestinationRepository.CreateEnterExitsList(destination);
                newDestination = new DestinationExhibitsModel(destination.id, destination.mapPointId, destination.destinationName, destination.statusTypeId, destination.MapPoint.mapPointTypeId, destination.shortDescription, destination.longDescription, destination.MapPoint.latitude, destination.MapPoint.longitude, destination.openingTime, destination.closingTime, destination.DestinationPreview.FirstOrDefault().previewPath, destination.DestinationThumb.FirstOrDefault().thumbPath, photoList, enterExitsList);
            }
            else if (destination.MapPoint.MapPointType.type == "Attractions" )
            {
                List<DestinationPhotosModel> photoList = _DestinationRepository.CreatePhotoList(destination);
                List<DestinationEnterExitsModel> enterExitsList = _DestinationRepository.CreateEnterExitsList(destination);
                List<DestinationAdditionalFeesModel> additionalFees = _DestinationRepository.CreateAdditionalFees(destination);
                newDestination = new DestinationAttractionsModel(destination.id, destination.mapPointId, destination.destinationName, destination.statusTypeId, destination.MapPoint.mapPointTypeId, destination.shortDescription, destination.longDescription, destination.MapPoint.latitude, destination.MapPoint.longitude, destination.openingTime, destination.closingTime, destination.DestinationPreview.FirstOrDefault().previewPath, destination.DestinationThumb.FirstOrDefault().thumbPath, photoList, enterExitsList, additionalFees);
            }
            else if (destination.MapPoint.MapPointType.type == "Dining" )
            {
                List<DestinationPhotosModel> photoList = _DestinationRepository.CreatePhotoList(destination);
                List<DestinationEnterExitsModel> enterExitsList = _DestinationRepository.CreateEnterExitsList(destination);
                List<DestinationMenuModel> menu = _DestinationRepository.CreateMenu(destination);
                newDestination = new DestinationDiningModel(destination.id, destination.mapPointId, destination.destinationName, destination.statusTypeId, destination.MapPoint.mapPointTypeId, destination.shortDescription, destination.longDescription, destination.MapPoint.latitude, destination.MapPoint.longitude, destination.openingTime, destination.closingTime, destination.DestinationPreview.FirstOrDefault().previewPath, destination.DestinationThumb.FirstOrDefault().thumbPath, photoList, menu, enterExitsList);
            }
            else if(destination.MapPoint.MapPointType.type ==  "Gifts/Souvenirs" )
            {
                List<DestinationPhotosModel> photoList = _DestinationRepository.CreatePhotoList(destination);
                List<DestinationEnterExitsModel> enterExitsList = _DestinationRepository.CreateEnterExitsList(destination);
                newDestination = new DestinationGiftSouvenirsModel(destination.id, destination.mapPointId, destination.destinationName, destination.statusTypeId, destination.MapPoint.mapPointTypeId, destination.shortDescription, destination.longDescription, destination.MapPoint.latitude, destination.MapPoint.longitude, destination.openingTime, destination.closingTime, destination.DestinationPreview.FirstOrDefault().previewPath, destination.DestinationThumb.FirstOrDefault().thumbPath, photoList, enterExitsList);
            }
            else if (destination.MapPoint.MapPointType.type == "Facilities" )
            {
                newDestination = new DestinationModel(destination.id, destination.mapPointId, destination.destinationName, destination.statusTypeId, destination.MapPoint.mapPointTypeId, destination.shortDescription, destination.longDescription, destination.MapPoint.latitude, destination.MapPoint.longitude, destination.openingTime, destination.closingTime, destination.DestinationPreview.FirstOrDefault().previewPath, destination.DestinationThumb.FirstOrDefault().thumbPath);
            }
            else if (destination.MapPoint.MapPointType.type == "NavigationPoint" )
            {
                return null;
            }
            return newDestination;
        }
        public int SaveDatabaseDestination(DestinationModel newDestination)
        {
            MapPoint dbMapPoint = new MapPoint();
            dbMapPoint.mapPointId = newDestination.MapPointID;
            dbMapPoint.name = newDestination.Name;
            dbMapPoint.description = newDestination.LongDescription;
            dbMapPoint.latitude = newDestination.Latitude;
            dbMapPoint.longitude = newDestination.Longitude;
            dbMapPoint.mapPointTypeId = newDestination.MapPointTypeID;

            //obsolete columns
            dbMapPoint.imageX = 1;
            dbMapPoint.imageY = 1;

            _phillyZooDatabaseEntities.MapPoint.Add(dbMapPoint);
            _phillyZooDatabaseEntities.SaveChanges();

            DestinationObjectLayer dbDestination = new DestinationObjectLayer();
            dbDestination.id = newDestination.ID;
            dbDestination.mapPointId = dbMapPoint.mapPointId;
            dbDestination.statusTypeId = newDestination.StatusID;
            dbDestination.destinationName = dbMapPoint.name;
            dbDestination.shortDescription = newDestination.ShortDescription;
            dbDestination.longDescription = dbMapPoint.description;
            dbDestination.openingTime = newDestination.OpeningTime;
            dbDestination.closingTime = newDestination.ClosingTime;

            _phillyZooDatabaseEntities.DestinationObjectLayer.Add(dbDestination);
            _phillyZooDatabaseEntities.SaveChanges();

            //if (newDestination is IMenu)
            //{
            //    IMenu menuItem = (IMenu)newDestination;
            //    SaveDatabaseMenu(menuItem);
            //}

            //if (newDestination is IPhotos)
            //{
            //    IPhotos photoItem = (IPhotos)newDestination;
            //    SaveDatabasePhotos(photoItem);
            //}

            //if (newDestination is IAdditionalFees)
            //{
            //    IAdditionalFees additionalFeesItem = (IAdditionalFees)newDestination;
            //    SaveDatabaseAdditionalFees(additionalFeesItem);
            //}

            //if (newDestination is IEnterExits)
            //{
            //    IEnterExits enterExits = (IEnterExits)newDestination;
            //    SaveDatabaseEnterExits(enterExits);
            //}

            return dbDestination.id;
        }