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;
 }
Esempio n. 2
0
        public ActionResult CreatePhotos(DestinationPhotosModel newPhotoModel, HttpPostedFileBase libraryPhoto)
        {
            var dbInt = _destinationRepository.GetDestinationByID(newPhotoModel.DestinationLayerID).ID;

            string addedPhotoName = Path.GetFileName(libraryPhoto.FileName);
            string pathForDatabase = dbInt + "_" + addedPhotoName;
            string fullPathForDir = Path.Combine(Server.MapPath(ConfigurationManager.AppSettings["destinationPhotoLibraryDir"]), pathForDatabase);
            newPhotoModel.ImagePath = pathForDatabase;

            libraryPhoto.SaveAs(fullPathForDir);

            _destinationRepository.SaveDatabasePhotos(newPhotoModel);
            return RedirectToAction("Index");
        }
Esempio n. 3
0
        public ActionResult CreatePhotos(int destinationLayerId)
        {
            DestinationPhotosModel photos = new DestinationPhotosModel();
            photos.DestinationLayerID = destinationLayerId;

            return View(photos);
        }
        public void SaveDatabasePhotos(DestinationPhotosModel photo)
        {
            if(photo != null)
            {
                //check to see if a photo with this name already exists in the db!! If it does we have to delete from the db and the directory before saving again

                DestinationPhotos dbPhoto = new DestinationPhotos();
                dbPhoto.id = photo.ID;
                dbPhoto.destinationLayerId = photo.DestinationLayerID;
                dbPhoto.imagePath = photo.ImagePath;

                _phillyZooDatabaseEntities.DestinationPhotos.Add(dbPhoto);

                _phillyZooDatabaseEntities.SaveChanges();
            }
        }
 void IDestinationRepository.SaveDatabasePhotos(DestinationPhotosModel photo)
 {
 }