コード例 #1
0
 IEnumerable<DestinationModel> IDestinationRepository.GetDestinations()
 {
     List<DestinationModel> listForController = new List<DestinationModel>();
     for(int i = 1; i <= 5; i++)
     {
         DestinationModel destinationForList = new DestinationModel(i, (i * 100), "Destination " + i, 1, 255, "Short Description " + i, "Long Description " + i, (i *111.111m), (i *111.111m), DateTime.Now, DateTime.Now, "previewPhoto", "thumbnailPhoto");
         listForController.Add(destinationForList);
     }
     return listForController;
 }
コード例 #2
0
        public ActionResult CreateDestination()
        {
            IEnumerable<MapPointStatusType> listOfMapPointStatusTypes = _destinationRepository.ListOfMapPointStatusTypes();
            IEnumerable<SelectListItem> mapPointStatusTypeDropDownList = new List<SelectListItem>();
            mapPointStatusTypeDropDownList = listOfMapPointStatusTypes.Select(m => new SelectListItem() { Value = m.id.ToString(), Text = m.status });

            IEnumerable<MapPointType> listOfMapPointTypes = _destinationRepository.ListOfMapPointTypes();
            IEnumerable<SelectListItem> mapPointTypeDropDownList = new List<SelectListItem>();
            mapPointTypeDropDownList = listOfMapPointTypes.Select(m => new SelectListItem() { Value = m.mapPointTypeId.ToString(), Text = m.type });

            ViewBag.MapPointTypeList = mapPointTypeDropDownList;
            ViewBag.MapPointStatusTypeList = mapPointStatusTypeDropDownList;

            DestinationModel destination = new DestinationModel();
            return View(destination);
        }
コード例 #3
0
        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;
        }
コード例 #4
0
        public ActionResult CreateDestination(DestinationModel newDestination, HttpPostedFileBase thumbnailPhoto, HttpPostedFileBase previewPhoto)
        {
            int dbInt = _destinationRepository.SaveDatabaseDestination(newDestination);

            string thumbnailPhotoFileName = Path.GetFileName(thumbnailPhoto.FileName);
            string thumbnailSuffix = Path.GetExtension(thumbnailPhotoFileName);
            string pathForDatabaseThumb = dbInt + "_thumbnail" + thumbnailSuffix.ToString();

            string previewPhotoFileName = Path.GetFileName(previewPhoto.FileName);
            string previewSuffix = Path.GetExtension(previewPhotoFileName);
            string pathForDatabasePreview = dbInt + previewSuffix.ToString();

            string fullPathForThumb = Path.Combine(Server.MapPath(ConfigurationManager.AppSettings["destinationThumbnailDir"]), pathForDatabaseThumb);
            string fullPathForPreview = Path.Combine(Server.MapPath(ConfigurationManager.AppSettings["destinationPreviewDir"]), pathForDatabasePreview);

            thumbnailPhoto.SaveAs(fullPathForThumb);
            previewPhoto.SaveAs(fullPathForPreview);

            _destinationRepository.SaveThumbnailPathToDatabase(dbInt, pathForDatabaseThumb);
            _destinationRepository.SavePreviewPathToDatabase(dbInt, pathForDatabasePreview);

            return RedirectToAction("Index");
        }
コード例 #5
0
        public ActionResult EditDestination(DestinationModel updatedDestination, HttpPostedFileBase previewPhoto, HttpPostedFileBase thumbnailPhoto)
        {
            var thumbnailPhotoFileName = Path.GetFileName(thumbnailPhoto.FileName);
            var thumbnailSuffix = Path.GetExtension(thumbnailPhotoFileName);
            var pathForDatabaseThumb = updatedDestination.ID + "_thumbnail" + thumbnailSuffix.ToString();

            var previewPhotoFileName = Path.GetFileName(previewPhoto.FileName);
            var previewSuffix = Path.GetExtension(previewPhotoFileName);
            var pathForDatabasePreview = updatedDestination.ID + previewSuffix.ToString();

            var fullPathForThumb = Path.Combine(Server.MapPath(ConfigurationManager.AppSettings["destinationThumbnailDir"]), pathForDatabaseThumb);
            var fullPathForPreview = Path.Combine(Server.MapPath(ConfigurationManager.AppSettings["destinationPreviewDir"]), pathForDatabasePreview);

            if(System.IO.File.Exists(fullPathForThumb))
            {
                System.IO.File.Delete(fullPathForThumb);
            }
            if(System.IO.File.Exists(fullPathForPreview))
            {
                System.IO.File.Delete(fullPathForPreview);
            }

            thumbnailPhoto.SaveAs(fullPathForThumb);
            previewPhoto.SaveAs(fullPathForPreview);

            _destinationRepository.EditDatabaseDestination(updatedDestination, previewPhoto, thumbnailPhoto);
            return RedirectToAction("DetailDestination", new { id = updatedDestination.ID });
        }
コード例 #6
0
 public ActionResult CreateType(DestinationModel postedType)
 {
     DestinationModel model = null;
     switch (postedType.MapPointTypeID)
     {
         case 2:
             model =  new DestinationExhibitsModel();
             break;
         case 3:
             model = new DestinationExhibitsModel();
             break;
         case 4:
             model = new DestinationAttractionsModel();
             break;
         case 5:
             model = new DestinationGiftSouvenirsModel();
             break;
         case 6:
             model = new DestinationDiningModel();
             break;
         case 7:
             model = new DestinationModel();
             break;
         default:
             model = new DestinationModel();
             break;
     }
     model.MapPointTypeID = postedType.MapPointTypeID;
     return View("CreateDestination", model);
 }
コード例 #7
0
        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;
        }
コード例 #8
0
        public void EditDatabaseDestination(DestinationModel editedDestination, HttpPostedFileBase previewPhoto, HttpPostedFileBase thumbnailPhoto)
        {
            DestinationObjectLayer destinationToEdit = _phillyZooDatabaseEntities.DestinationObjectLayer.Include("MapPoint")
                                                                                                        .Include("MapPointStatusType")
                                                                                                        .Include("DestinationMenu")
                                                                                                        .Include("DestinationAdditionalFees")
                                                                                                        .Include("DestinationPhotos")
                                                                                                        .Include("DestinationEnterExits")
                                                                                                        .Include("DestinationPreview")
                                                                                                        .Include("DestinationThumb")
                                                                                                        .FirstOrDefault(m => m.id == editedDestination.ID);

            if (destinationToEdit != null)
            {
                destinationToEdit.statusTypeId = editedDestination.StatusID;
                destinationToEdit.destinationName = editedDestination.Name;
                destinationToEdit.shortDescription = editedDestination.ShortDescription;
                destinationToEdit.longDescription = editedDestination.LongDescription;
                destinationToEdit.openingTime = editedDestination.OpeningTime;
                destinationToEdit.closingTime = editedDestination.ClosingTime;

                var thumbnailPhotoFileName = Path.GetFileName(thumbnailPhoto.FileName);
                var previewPhotoFileName = Path.GetFileName(previewPhoto.FileName);
                var thumbnailSuffix = Path.GetExtension(thumbnailPhotoFileName);
                var previewSuffix = Path.GetExtension(previewPhotoFileName);
                var dbThumbnailPath = editedDestination.ID.ToString() + "_thumbnail" + thumbnailSuffix.ToString();
                var dbPreviewPath = editedDestination.ID.ToString() + previewSuffix.ToString();

                //create standardized name for preview and thumb...
                var fullThumbPath = Path.Combine(ConfigurationManager.AppSettings["destinationThumbnailDir"], dbThumbnailPath);
                var fullPreviewPath = Path.Combine(ConfigurationManager.AppSettings["destinationPreviewDir"], dbPreviewPath);

                SavePreviewPathToDatabase(editedDestination.ID, dbPreviewPath);
                SaveThumbnailPathToDatabase(editedDestination.ID, dbThumbnailPath);
                _phillyZooDatabaseEntities.SaveChanges();
            }
        }
コード例 #9
0
 DestinationModel IDestinationRepository.GetDestinationByID(int id)
 {
     DestinationModel destination = new DestinationModel(1, 100, "Destination " + 1, 1, 255, "Short Description 1", "Long Description 1", 111.111m, 111.111m, DateTime.Now, DateTime.Now, "previewPhoto", "thumbnailPhoto");
     return destination;
 }
コード例 #10
0
 void IDestinationRepository.EditDatabaseDestination(DestinationModel editedDestination, HttpPostedFileBase previewPhoto, HttpPostedFileBase thumbnailPhoto)
 {
     throw new NotImplementedException();
 }
コード例 #11
0
        IEnumerable<DestinationModel> IDestinationRepository.SearchDestinations(string name)
        {
            List<DestinationModel> listToReturn = new List<DestinationModel>();

            DestinationModel destination1 = new DestinationModel(1, 100, name.ToString(), 1, 255, "Short Description", "Long Description", 111.111m, 111.111m, DateTime.Now, DateTime.Now, "previewPhoto", "thumbnailPhoto");
            listToReturn.Add(destination1);
            DestinationModel destination2 = new DestinationModel(2, 200, name.ToString() + " and more", 1, 255, "Short Description", "Long Description", 333.333m, 333.333m, DateTime.Now, DateTime.Now, "previewPhoto", "thumbnailPhoto");
            listToReturn.Add(destination1);

            return listToReturn;
        }
コード例 #12
0
 int IDestinationRepository.SaveDatabaseDestination(DestinationModel newDestination)
 {
     Console.WriteLine("Saved!");
     return 1;
 }