public GalleryController(GalleryRepository galleryRepo, PaginatedMetaService paginatedMetaService, GalleryImageRepository galleryImageRepo, IMapper mapper)
 {
     _galleryRepo          = galleryRepo;
     _galleryImageRepo     = galleryImageRepo;
     _paginatedMetaService = paginatedMetaService;
     _mapper = mapper;
 }
Exemplo n.º 2
0
        public ActionResult Index(string theme)
        {
            if (!string.IsNullOrWhiteSpace(theme))
            {
                string dir = Server.MapPath("content/themes/" + theme); //make sure theme dir exists
                if (Directory.Exists(dir))
                {
                    Session["theme"] = theme;
                }
            }

            string            re  = Request.RawUrl;
            GalleryRepository rep = this.GetGalleryRepository();

            ViewBag.Folders = rep.Folders;

            var photoRepository = new PhotoRepository();

            PhotosModel photosModel = new PhotosModel()
            {
                PicCount = photoRepository.GetImagesCount()
                           //    Categorieses = photoRepository.GetCategories()
            };

            ViewBag.Categories = photoRepository.GetCategories();


            ViewBag.HtmlContent = rep.RootFolder.GetHtmlContentIfAny(); //initial html content from root folder
            return(View("Index"));
        }
Exemplo n.º 3
0
 /// <summary>
 /// Gets the ID of the template gallery.
 /// </summary>
 /// <returns>System.Int32.</returns>
 private static int GetTemplateGalleryId()
 {
     using (var repo = new GalleryRepository())
     {
         return(repo.Where(g => g.IsTemplate).Single().GalleryId);
     }
 }
Exemplo n.º 4
0
        /// <summary>
        /// Persist information about the specified <paramref name="ex">exception</paramref> to the data store and return
        /// the instance. Send an e-mail notification if that option is enabled.
        /// </summary>
        /// <param name="ex">The exception to be recorded to the data store.</param>
        /// <param name="appSettings">The application settings containing the e-mail configuration data.</param>
        /// <param name="galleryId">The ID of the gallery the <paramref name="ex">exception</paramref> is associated with.
        /// If the exception is not specific to a particular gallery, specify null.</param>
        /// <param name="gallerySettingsCollection">The collection of gallery settings for all galleries. You may specify
        /// null if the value is not known; however, this value must be specified for e-mail notification to occur.</param>
        /// <returns>An instance of <see cref="IEvent" />.</returns>
        /// <exception cref="ArgumentNullException">Thrown when <paramref name="ex"/> is null.</exception>
        public static IEvent RecordError(Exception ex, IAppSetting appSettings, int?galleryId = null, IGallerySettingsCollection gallerySettingsCollection = null)
        {
            if (ex == null)
            {
                throw new ArgumentNullException("ex");
            }

            if (galleryId == null)
            {
                using (var repo = new GalleryRepository())
                {
                    galleryId = repo.Where(g => g.IsTemplate).First().GalleryId;
                }
            }

            var ev = new Event(ex, galleryId.Value);

            Save(ev);

            if (gallerySettingsCollection != null)
            {
                SendEmail(ev, appSettings, gallerySettingsCollection);
            }

            if (appSettings != null)
            {
                ValidateLogSize(appSettings.MaxNumberErrorItems);
            }

            return(ev);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Persist information about the specified <paramref name="msg" /> to the data store and return
        /// the instance. Send an e-mail notification if that option is enabled.
        /// </summary>
        /// <param name="msg">The message to be recorded to the data store.</param>
        /// <param name="eventType">Type of the event. Defaults to <see cref="EventType.Info" /> if not specified.</param>
        /// <param name="galleryId">The ID of the gallery the <paramref name="msg" /> is associated with.
        /// If the message is not specific to a particular gallery, specify null.</param>
        /// <param name="gallerySettingsCollection">The collection of gallery settings for all galleries. You may specify
        /// null if the value is not known; however, this value must be specified for e-mail notification to occur.</param>
        /// <param name="appSettings">The application settings. You may specify null if the value is not known.</param>
        /// <param name="data">Additional optional data to record. May be null.</param>
        /// <returns>An instance of <see cref="IEvent" />.</returns>
        /// <exception cref="System.ArgumentOutOfRangeException">galleryId</exception>
        /// <exception cref="ArgumentOutOfRangeException">Thrown when <paramref name="galleryId" /> is <see cref="Int32.MinValue" />.</exception>
        public static IEvent RecordEvent(string msg, EventType eventType = EventType.Info, int?galleryId = null, IGallerySettingsCollection gallerySettingsCollection = null, IAppSetting appSettings = null, Dictionary <string, string> data = null)
        {
            if (galleryId == Int32.MinValue)
            {
                throw new ArgumentOutOfRangeException("galleryId", String.Format("The galleryId parameter must represent an existing gallery. Instead, it was {0}", galleryId));
            }

            if (galleryId == null)
            {
                using (var repo = new GalleryRepository())
                {
                    galleryId = repo.Where(g => g.IsTemplate).First().GalleryId;
                }
            }

            var ev = new Event(msg, galleryId.Value, eventType, data);

            Save(ev);

            if (appSettings != null && gallerySettingsCollection != null)
            {
                SendEmail(ev, appSettings, gallerySettingsCollection);
            }

            if (appSettings != null)
            {
                ValidateLogSize(appSettings.MaxNumberErrorItems);
            }

            return(ev);
        }
Exemplo n.º 6
0
 public FooterViewComponent(GalleryRepository galleryRepo, NoticeRepository noticeRepo, SetupRepository setupRepo, PageCategoryRepository pageCategoryRepo)
 {
     _galleryRepo      = galleryRepo;
     _noticeRepo       = noticeRepo;
     _setupRepo        = setupRepo;
     _pageCategoryRepo = pageCategoryRepo;
 }
Exemplo n.º 7
0
 /// <summary>
 /// Gets the name of the connection string for the gallery data.
 /// </summary>
 /// <returns>System.String.</returns>
 private static string GetConnectionStringName()
 {
     using (var repo = new GalleryRepository())
     {
         return(repo.ConnectionStringName);
     }
 }
 public UnitOfWork(ApplicationDbContext context)
 {
     this._context = context;
     Programmes = new ProgrammeRepository(context);
     UsefulLinks = new UsefulLinkRepository(context);
     NewsArticles = new NewsArticleRepository(context);
     Gallerys = new GalleryRepository(context);
 }
 public GalleryImageController(FileHelper fileHelper, IMapper mapper, GalleryImageService galleryImageService, GalleryImageRepository galleryImageRepo, PaginatedMetaService paginatedMetaService, GalleryRepository galleryRepository)
 {
     _galleryImageService  = galleryImageService;
     _galleryImageRepo     = galleryImageRepo;
     _paginatedMetaService = paginatedMetaService;
     _mapper            = mapper;
     _fileHelper        = fileHelper;
     _galleryRepository = galleryRepository;
 }
Exemplo n.º 10
0
        public bool AddTagToGallery(int galleryID, int tagID)
        {
            if (galleryID == 0 || tagID == 0)
            {
                return(false);
            }

            return(GalleryRepository.AddTag(galleryID, tagID));
        }
        public async void Test_Gallery_GalleryImages_RelationShip()
        {
            using (var context = GetContextWithData())
            {
                GalleryRepository _galleryRepository = new GalleryRepository(context);
                var GalleryImages = await _galleryRepository.GetSelectedImages();

                Assert.Equal(3, GalleryImages.Count);
            }
        }
Exemplo n.º 12
0
 public HeaderViewComponent(EmailSenderService emailSenderService, GalleryRepository galleryRepo, AppointmentRepository appoitmentRepo, NoticeRepository noticeRepo, SetupRepository setupRepo, PageCategoryRepository pageCategoryRepo, EventRepository eventRepo, ServicesRepository serviceRepository)
 {
     _galleryRepo        = galleryRepo;
     _noticeRepo         = noticeRepo;
     _setupRepo          = setupRepo;
     _pageCategoryRepo   = pageCategoryRepo;
     _eventRepo          = eventRepo;
     _appointmentRepo    = appoitmentRepo;
     _serviceRepository  = serviceRepository;
     _emailSenderService = emailSenderService;
 }
Exemplo n.º 13
0
        public static List <AlbumPhoto> GetPhtotoInAlbum(int albumId)
        {
            var pathGellaryPhoto           = ConfigurationManager.AppSettings["pathGalleryPhoto"];
            IGalleryRepository galleryRepo = new GalleryRepository();
            var photos = galleryRepo.GetPhotoInAlbum(albumId);

            foreach (var photo in photos)
            {
                photo.Path = pathGellaryPhoto + photo.Path;
            }
            return(photos);
        }
Exemplo n.º 14
0
 public UnitOfWork(ContextDb context)
 {
     this.context = context;
     Language     = new LanguageRepository(context);
     LanguageData = new LanguageDataRepository(context);
     Partners     = new PartnerRepository(context);
     Photo        = new PhotoRepository(context);
     Slider       = new SliderRepository(context);
     Volunteer    = new VolunteerRepository(context);
     Gallery      = new GalleryRepository(context);
     News         = new NewsRepository(context);
     Tag          = new TagRepository(context);
 }
Exemplo n.º 15
0
        public ActionResult Index()
        {
            var objGalleryRepository = new GalleryRepository();
            List <GalleryViewModel> objEntityList = objGalleryRepository.Search(GalleryFlags.SelectAll.GetHashCode(), new GalleryViewModel()
            {
                Id = 0
            });

            if (objEntityList.Count == 0)
            {
            }

            return(View(objEntityList));
        }
Exemplo n.º 16
0
        public ActionResult Edit(int id, GalleryViewModel objEntity)
        {
            var    objStudentRepository = new GalleryRepository();
            string fileName             = string.Empty;


            objEntity.Id = id;

            objEntity.DeleteFileName = objEntity.FileName;

            if (!string.IsNullOrEmpty(objEntity.UpFile.FileName))
            {
                fileName           = Guid.NewGuid().ToString() + Path.GetExtension(objEntity.UpFile.FileName);
                objEntity.FileName = fileName;
            }

            objEntity = objStudentRepository.Edit(GalleryFlags.UpdateByID.GetHashCode(), objEntity);
            if (objEntity.Result == ResultFlags.Success.GetHashCode())
            {
                if ((objEntity.DeleteFileName != null || objEntity.DeleteFileName != string.Empty) && !string.IsNullOrEmpty(objEntity.UpFile.FileName))
                {
                    FileInfo file = new FileInfo(Server.MapPath(ApplicationConstant.UPLOADED_EMPLOYER_GALLERY_PATH + objEntity.DeleteFileName));

                    if (file.Exists)
                    {
                        file.Delete();
                    }
                    string path = Path.Combine(Server.MapPath(ApplicationConstant.UPLOADED_EMPLOYER_GALLERY_PATH), fileName);
                    // WebImage.Save()
                    objEntity.UpFile.SaveAs(path);
                }

                this.Flash("success", "Student Details updated successfully");
                return(RedirectToAction("Index"));
            }
            else if (objEntity.Result == ResultFlags.Failure.GetHashCode())
            {
                this.Flash("error", "Student Details failed to Update");
            }
            else if (objEntity.Result == ResultFlags.Duplicate.GetHashCode())
            {
                this.Flash("warning", "Student Name is Already Exist");
            }



            return(View(objEntity));
        }
Exemplo n.º 17
0
        public static Album GetByURL(string url)
        {
            var pathGalleryPhoto           = ConfigurationManager.AppSettings["pathGalleryPhoto"];
            IGalleryRepository galleryRepo = new GalleryRepository();
            var album = galleryRepo.GetByURL(url);

            if (album == null)
            {
                throw new NotFoundException("Альбом не найден", "");
            }
            foreach (var photo in album.Photos)
            {
                photo.Path = pathGalleryPhoto + photo.Path;
            }
            return(album);
        }
Exemplo n.º 18
0
        public ActionResult Details(int id)
        {
            var objStudentRepository = new GalleryRepository();
            var objEntity            = new GalleryViewModel();

            objEntity = objStudentRepository.Select(GalleryFlags.SelectByID.GetHashCode(), new GalleryViewModel()
            {
                Id = id
            }).FirstOrDefault();
            if (objEntity == null)
            {
                return(RedirectToAction("Index"));
            }

            return(View(objEntity));
        }
Exemplo n.º 19
0
        /// <summary>
        /// Persist this gallery object to the data store.
        /// </summary>
        public void Save()
        {
            bool isNew = IsNew;

            using (var repo = new GalleryRepository())
            {
                if (IsNew)
                {
                    var galleryDto = new GalleryDto {
                        Description = Description, DateAdded = CreationDate
                    };
                    repo.Add(galleryDto);
                    repo.Save();
                    _id = galleryDto.GalleryId;
                }
                else
                {
                    var galleryDto = repo.Find(GalleryId);

                    if (galleryDto != null)
                    {
                        galleryDto.Description = Description;
                        repo.Save();
                    }
                    else
                    {
                        throw new BusinessException(String.Format(CultureInfo.CurrentCulture, "Cannot save gallery: No existing gallery with Gallery ID {0} was found in the database.", GalleryId));
                    }
                }
            }

            // For new galleries, configure it and then trigger the created event.
            if (isNew)
            {
                Configure();

                EventHandler <GalleryCreatedEventArgs> galleryCreated = GalleryCreated;
                if (galleryCreated != null)
                {
                    galleryCreated(null, new GalleryCreatedEventArgs(GalleryId));
                }
            }

            Factory.ClearAllCaches();
        }
Exemplo n.º 20
0
        public ActionResult Create(GalleryViewModel objEntity)
        {
            GalleryViewModel  objFileUpRepository = new GalleryViewModel();
            GalleryRepository objfileRepository   = new GalleryRepository();
            string            fileName            = string.Empty;

            if (ModelState.IsValid)
            {
                if (!string.IsNullOrEmpty(objEntity.UpFile.FileName))
                {
                    fileName           = Guid.NewGuid().ToString() + Path.GetExtension(objEntity.UpFile.FileName);
                    objEntity.FileName = fileName;
                }

                objfileRepository.Insert(objEntity);

                if (objEntity.Result == ResultFlags.Success.GetHashCode())
                {
                    //save image http://www.w3schools.com/aspnet/webpages_ref_helpers.asp


                    //file name
                    if (!string.IsNullOrEmpty(objEntity.UpFile.FileName))
                    {
                        string path = Path.Combine(Server.MapPath(ApplicationConstant.UPLOADED_EMPLOYER_GALLERY_PATH), fileName);
                        // WebImage.Save()
                        objEntity.UpFile.SaveAs(path);
                    }
                    this.Flash("success", "Image Addd successfully ");
                    return(RedirectToAction("Index"));
                }

                else if (objEntity.Result == ResultFlags.Failure.GetHashCode())
                {
                    this.Flash("error", "Faild to Insert File");
                    return(RedirectToAction("Index"));
                }
                else if (objEntity.Result == ResultFlags.Duplicate.GetHashCode())
                {
                    this.Flash("warning", "File is Already Exist");
                    return(RedirectToAction("Index"));
                }
            }
            return(View(objEntity));
        }
Exemplo n.º 21
0
        /// <summary>
        /// Persist this gallery instance to the data store.
        /// </summary>
        public void Save()
        {
            bool isNew = IsNew;

            using (var repo = new GalleryRepository())
            {
                if (IsNew)
                {
                    var galleryDto = new GalleryDto {
                        Description = Description, DateAdded = CreationDate
                    };
                    repo.Add(galleryDto);
                    repo.Save();
                    _id = galleryDto.GalleryId;
                }
                else
                {
                    var galleryDto = repo.Find(GalleryId);

                    if (galleryDto != null)
                    {
                        galleryDto.Description = Description;
                        repo.Save();
                    }
                    else
                    {
                        throw new BusinessException(String.Format(CultureInfo.CurrentCulture, "Cannot save gallery: No existing gallery with Gallery ID {0} was found in the database.", GalleryId));
                    }
                }
            }

            // For new galleries, configure it and then trigger the created event.
            if (isNew)
            {
                Validate();

                Factory.ClearGalleryCache(); // Needed so LoadGalleries(), called by AddDefaultRolesToRoleAlbumTable(), pulls new gallery from data store

                AddDefaultRolesToRoleAlbumTable();
            }

            Factory.ClearAllCaches();
        }
Exemplo n.º 22
0
        /// <summary>
        /// Permanently delete the current gallery from the data store, including all related records. This action cannot
        /// be undone.
        /// </summary>
        public void Delete()
        {
            //Factory.GetDataProvider().Gallery_Delete(this);
            OnBeforeDeleteGallery();

            // Cascade delete relationships should take care of any related records not deleted in OnBeforeDeleteGallery.
            using (var repo = new GalleryRepository())
            {
                var galleryDto = repo.Find(GalleryId);
                if (galleryDto != null)
                {
                    // Delete gallery. Cascade delete rules in DB will delete related records.
                    repo.Delete(galleryDto);
                    repo.Save();
                }
            }

            Factory.ClearAllCaches();
        }
 public UnitOfWork(GrowingPlantsContext context)
 {
     UserRepository                = new UserRepository(context);
     TreeRepository                = new TreeRepository(context);
     MeasurementUnitRepository     = new MeasurementUnitRepository(context);
     LightRepository               = new LightRepository(context);
     HumidityRepository            = new HumidityRepository(context);
     TemperatureRepository         = new TemperatureRepository(context);
     FavoriteTreeRepository        = new FavoriteTreeRepository(context);
     CountryRepository             = new CountryRepository(context);
     PlantingProcessRepository     = new PlantingProcessRepository(context);
     PlantingEnvironmentRepository = new PlantingEnvironmentRepository(context);
     ProcessStepRepository         = new ProcessStepRepository(context);
     PlantingActionRepository      = new PlantingActionRepository(context);
     RecurrenceRepository          = new RecurrenceRepository(context);
     NotificationRepository        = new NotificationRepository(context);
     PlantingSpotRepository        = new PlantingSpotRepository(context);
     PlantTypeRepository           = new PlantTypeRepository(context);
     GalleryRepository             = new GalleryRepository(context);
     PictureRepository             = new PictureRepository(context);
 }
Exemplo n.º 24
0
        public ActionResult Main()
        {
            string            re  = Request.RawUrl;
            GalleryRepository rep = this.GetGalleryRepository();

            ViewBag.Folders = rep.Folders;

            var photoRepository = new PhotoRepository();

            //PhotosModel photosModel = new PhotosModel()
            //{
            //    PicCount = photoRepository.GetImagesCount()
            //    //    Categorieses = photoRepository.GetCategories()

            //};

            ViewBag.Categories = photoRepository.GetCategories();


            ViewBag.HtmlContent = rep.RootFolder.GetHtmlContentIfAny(); //initial html content from root folder
            return(View("Index"));
        }
Exemplo n.º 25
0
        public JsonResult EditImageInfo(FormCollection formValues)
        {
            GalleryRepository rep   = this.GetGalleryRepository();
            PGImage           image = rep.GetImageFromVPath(formValues["ImageVPathEditImageInfo"]);

            if (image == null)
            {
                Response.StatusCode = 400;
                return(Json(new { error = "Image not found at " + formValues["ImageVPath"] }));
            }

            image.FriendlyName = formValues["ImageFriendlyName"];
            image.ImageDescr   = formValues["ImageDescription"];

            if (!ValidName(image.FriendlyName) || !ValidName(image.ImageDescr))
            {
                Response.StatusCode = 400;
                return(Json(new { error = "Image not found at " + formValues["ImageVPath"] }));
            }

            rep.UpdateImageInfo(image);

            return(Json(new { ImageFriendlyName = image.FriendlyName, ImageDescr = image.ImageDescr }, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 26
0
        public static IList <Album> GetAll()
        {
            var pathGellaryPhoto           = ConfigurationManager.AppSettings["pathGalleryPhoto"];
            var pathDefaultPhoto           = ConfigurationManager.AppSettings["pathDefaultPhoto"];
            IGalleryRepository galleryRepo = new GalleryRepository();
            var albums = galleryRepo.GetAll().ToList();

            foreach (var album in albums)
            {
                if (album.HeadImage != "" && album.HeadImage != null)
                {
                    album.HeadImage = pathGellaryPhoto + album.HeadImage;
                }
                else
                {
                    album.HeadImage = pathDefaultPhoto;
                }
                foreach (var photo in album.Photos)
                {
                    photo.Path = pathGellaryPhoto + photo.Path;
                }
            }
            return(albums);
        }
Exemplo n.º 27
0
        public GalleryTest()
        {
            var repository = new GalleryRepository();

            _service = new GalleryService(repository);
        }
Exemplo n.º 28
0
        public IActionResult DetailsProduct(int productId = 0)
        {
            if (productId == 0)
            {
                return(null);
            }

            ApplicationDbContext database = new ApplicationDbContext();

            var qProduct = database.Tbl_Products.Where(c => c.ProductId == productId && c.IsShowProduct == true)
                           .Include(c => c.Tbl_Gallery)
                           .Include(c => c.Tbl_Category)
                           .Include(c => c.Tbl_FirstSubCategory)
                           .Include(c => c.Tbl_SecondSubCategory)
                           .Include(c => c.Tbl_LastSubCategory)
                           .Include(c => c.Tbl_Comments)
                           .Include(c => c.Tbl_User).SingleOrDefault();

            if (qProduct == null)
            {
                return(null);
            }

            CategoryRepository Rep_Category = new CategoryRepository();
            CommentRepository  Rep_Comment  = new CommentRepository();
            GalleryRepository  Rep_Gallery  = new GalleryRepository();
            UserRepository     Rep_User     = new UserRepository();

            var qGetComment = Rep_Comment.ShowListComments(productId);
            var qGetGallery = Rep_Gallery.GetGalleryProduct(productId);
            var qGetCat     = Rep_Category.ShowFirstSubCategory().Where(c => c.FirstSubCatId == qProduct.FirstSubCat_FK).FirstOrDefault();
            var qUser       = Rep_User.GetUserById(qProduct.UserId_FK);//***

            //----------------------------------
            qProduct.SeeProduct = qProduct.SeeProduct + 1;
            database.Tbl_Products.Update(qProduct);
            database.SaveChanges();

            VmDetailsProduct vm = new VmDetailsProduct();

            vm.ListCommentsProduct = qGetComment == null ? null : qGetComment;
            vm.ListImagesProduct   = qGetGallery == null ? null : qGetGallery;
            vm.CategoryId_FK       = qProduct.CategoryId_FK;
            vm.CategoryName        = qGetCat.FirstSubCatTitle;
            vm.CountProduct        = qProduct.CountProduct;
            vm.DefaultPic          = qProduct.DefaultPic;
            vm.Description         = qProduct.Description;
            vm.FirstSubCat_FK      = qProduct.FirstSubCat_FK;
            vm.LastSubCat_FK       = qProduct.LastSubCat_FK;
            vm.LinkProduct         = qGetCat.FirstSubCatId + "-" + qGetCat.FirstSubCatTitle;//For Example : 1-موبایل
            vm.OffProduct          = qProduct.OffProduct;
            vm.Price           = qProduct.Price;
            vm.ProductCode     = qProduct.ProductCode;
            vm.ProductId       = qProduct.ProductId;
            vm.ProductNameEN   = qProduct.ProductNameEN;
            vm.ProductNameFA   = qProduct.ProductNameFA;
            vm.SecondSubCat_FK = qProduct.SecondSubCat_FK;
            vm.SeeProduct      = qProduct.SeeProduct;
            vm.Weight          = qProduct.Weight;
            vm.SecondCatName   = qProduct.Tbl_SecondSubCategory.SecondSubCatTitle;
            vm.LastCatName     = qProduct.Tbl_LastSubCategory.LastSubCatTitle;
            vm.UserId_FK       = qUser.Id;
            vm.Username        = qUser.UserName;
            return(View(vm));
        }
 public GalleryController()
 {
     repository = new GalleryRepository();
 }
Exemplo n.º 30
0
		/// <summary>
		/// Gets the ID of the template gallery (that is, the one where <see cref="GalleryDto.IsTemplate" /> = <c>true</c>).
		/// </summary>
		/// <returns>System.Int32.</returns>
		public static int GetTemplateGalleryId()
		{
			if (!_templateGalleryId.HasValue)
			{
				using (var repo = new GalleryRepository())
				{
					_templateGalleryId = repo.Where(g => g.IsTemplate).Select(g => g.GalleryId).FirstOrDefault();
				}
			}

			return _templateGalleryId.Value;
		}
Exemplo n.º 31
0
 public GalleryController()
 {
     gr = new GalleryRepository();
 }
Exemplo n.º 32
0
 public GalleryService()
 {
     _galleryRepository = new GalleryRepository();
 }
Exemplo n.º 33
0
 /// <summary>
 /// Gets the name of the connection string for the gallery data.
 /// </summary>
 /// <returns>System.String.</returns>
 private static string GetConnectionStringName()
 {
     using (var repo = new GalleryRepository())
     {
         return repo.ConnectionStringName;
     }
 }
Exemplo n.º 34
0
        /// <summary>
        /// Permanently delete the current gallery from the data store, including all related records. This action cannot
        /// be undone.
        /// </summary>
        public void Delete()
        {
            //Factory.GetDataProvider().Gallery_Delete(this);
            OnBeforeDeleteGallery();

            // Cascade delete relationships should take care of any related records not deleted in OnBeforeDeleteGallery.
            using (var repo = new GalleryRepository())
            {
                var galleryDto = repo.Find(GalleryId);
                if (galleryDto != null)
                {
                    // Delete gallery. Cascade delete rules in DB will delete related records.
                    repo.Delete(galleryDto);
                    repo.Save();
                }
            }

            Factory.ClearAllCaches();
        }
 public GalleryController(GalleryRepository galleryRepository)
 {
     repository = galleryRepository;
 }
Exemplo n.º 36
0
        /// <summary>
        /// Persist information about the specified <paramref name="ex">exception</paramref> to the data store and return
        /// the instance. Send an e-mail notification if that option is enabled.
        /// </summary>
        /// <param name="ex">The exception to be recorded to the data store.</param>
        /// <param name="appSettings">The application settings containing the e-mail configuration data.</param>
        /// <param name="galleryId">The ID of the gallery the <paramref name="ex">exception</paramref> is associated with.
        /// If the exception is not specific to a particular gallery, specify null.</param>
        /// <param name="gallerySettingsCollection">The collection of gallery settings for all galleries. You may specify
        /// null if the value is not known; however, this value must be specified for e-mail notification to occur.</param>
        /// <returns>An instance of <see cref="IEvent" />.</returns>
        /// <exception cref="ArgumentNullException">Thrown when <paramref name="ex"/> is null.</exception>
        public static IEvent RecordError(Exception ex, IAppSetting appSettings, int? galleryId = null, IGallerySettingsCollection gallerySettingsCollection = null)
        {
            if (ex == null)
                throw new ArgumentNullException("ex");

            if (galleryId == null)
            {
                using (var repo = new GalleryRepository())
                {
                    galleryId = repo.Where(g => g.IsTemplate).First().GalleryId;
                }
            }

            var ev = new Event(ex, galleryId.Value);

            Save(ev);

            if (gallerySettingsCollection != null)
            {
                SendEmail(ev, appSettings, gallerySettingsCollection);
            }

            if (appSettings != null)
            {
                ValidateLogSize(appSettings.MaxNumberErrorItems);
            }

            return ev;
        }
Exemplo n.º 37
0
        /// <summary>
        /// Persist information about the specified <paramref name="msg" /> to the data store and return
        /// the instance. Send an e-mail notification if that option is enabled.
        /// </summary>
        /// <param name="msg">The message to be recorded to the data store.</param>
        /// <param name="eventType">Type of the event. Defaults to <see cref="EventType.Info" /> if not specified.</param>
        /// <param name="galleryId">The ID of the gallery the <paramref name="msg" /> is associated with.
        /// If the message is not specific to a particular gallery, specify null.</param>
        /// <param name="gallerySettingsCollection">The collection of gallery settings for all galleries. You may specify
        /// null if the value is not known; however, this value must be specified for e-mail notification to occur.</param>
        /// <param name="appSettings">The application settings. You may specify null if the value is not known.</param>
        /// <param name="data">Additional optional data to record. May be null.</param>
        /// <returns>An instance of <see cref="IEvent" />.</returns>
        /// <exception cref="System.ArgumentOutOfRangeException">galleryId</exception>
        /// <exception cref="ArgumentOutOfRangeException">Thrown when <paramref name="galleryId" /> is <see cref="Int32.MinValue" />.</exception>
        public static IEvent RecordEvent(string msg, EventType eventType = EventType.Info, int? galleryId = null, IGallerySettingsCollection gallerySettingsCollection = null, IAppSetting appSettings = null, Dictionary<string, string> data = null)
        {
            if (galleryId == Int32.MinValue)
                throw new ArgumentOutOfRangeException("galleryId", String.Format("The galleryId parameter must represent an existing gallery. Instead, it was {0}", galleryId));

            if (galleryId == null)
            {
                using (var repo = new GalleryRepository())
                {
                    galleryId = repo.Where(g => g.IsTemplate).First().GalleryId;
                }
            }

            var ev = new Event(msg, galleryId.Value, eventType, data);

            Save(ev);

            if (appSettings != null && gallerySettingsCollection != null)
            {
                SendEmail(ev, appSettings, gallerySettingsCollection);
            }

            if (appSettings != null)
            {
                ValidateLogSize(appSettings.MaxNumberErrorItems);
            }

            return ev;
        }
Exemplo n.º 38
0
 public MustOwnImageHandler(GalleryRepository galleryRepository)
 {
     this.galleryRepository = galleryRepository;
 }
Exemplo n.º 39
0
		/// <summary>
		/// Fill the <paramref name="emptyCollection"/> with all the galleries in the current application. The return value is the same reference
		/// as the parameter. The template gallery is not included (that is, the one where <see cref="GalleryDto.IsTemplate" /> = <c>true</c>).
		/// </summary>
		/// <param name="emptyCollection">An empty <see cref="IGalleryCollection"/> object to populate with the list of galleries in the current
		/// application. This parameter is required because the library that implements this interface does not have
		/// the ability to directly instantiate any object that implements <see cref="IGalleryCollection"/>.</param>
		/// <returns>
		/// Returns an <see cref="IGalleryCollection"/> representing the galleries in the current application. The returned object is the
		/// same object in memory as the <paramref name="emptyCollection"/> parameter.
		/// </returns>
		/// <exception cref="ArgumentNullException">Thrown when <paramref name="emptyCollection" /> is null.</exception>		/// 
		private static IGalleryCollection LoadGalleries(IGalleryCollection emptyCollection)
		{
			if (emptyCollection == null)
				throw new ArgumentNullException("emptyCollection");

			if (emptyCollection.Count > 0)
			{
				emptyCollection.Clear();
			}

			using (var repo = new GalleryRepository())
			{
				//var galleries = from i in ctx.Galleries where i.GalleryId > int.MinValue select i;
				var galleries = repo.Where(g => !g.IsTemplate);

				foreach (GalleryDto gallery in galleries)
				{
					IGallery g = emptyCollection.CreateEmptyGalleryInstance();

					g.GalleryId = gallery.GalleryId;
					g.Description = gallery.Description;
					g.CreationDate = gallery.DateAdded;
					g.Albums = FlattenGallery(gallery.GalleryId);

					emptyCollection.Add(g);
				}
			}

			return emptyCollection;
		}
Exemplo n.º 40
0
        /// <summary>
        /// Persist this gallery object to the data store.
        /// </summary>
        public void Save()
        {
            bool isNew = IsNew;

            using (var repo = new GalleryRepository())
            {
                if (IsNew)
                {
                    var galleryDto = new GalleryDto { Description = Description, DateAdded = CreationDate };
                    repo.Add(galleryDto);
                    repo.Save();
                    _id = galleryDto.GalleryId;
                }
                else
                {
                    var galleryDto = repo.Find(GalleryId);

                    if (galleryDto != null)
                    {
                        galleryDto.Description = Description;
                        repo.Save();
                    }
                    else
                    {
                        throw new BusinessException(String.Format(CultureInfo.CurrentCulture, "Cannot save gallery: No existing gallery with Gallery ID {0} was found in the database.", GalleryId));
                    }
                }
            }

            // For new galleries, configure it and then trigger the created event.
            if (isNew)
            {
                Configure();

                EventHandler<GalleryCreatedEventArgs> galleryCreated = GalleryCreated;
                if (galleryCreated != null)
                {
                    galleryCreated(null, new GalleryCreatedEventArgs(GalleryId));
                }
            }

            Factory.ClearAllCaches();
        }