protected async override Task OnInitializedAsync()
        {
            // return base.OnInitializedAsync();

            _galleryService = (GalleryService)ScopedServices.GetService(typeof(GalleryService));
            Items           = await _galleryService.GetGalleries(true).ToListAsync();
        }
Beispiel #2
0
 public ServicesManager()
 {
     Notifications = new NotificationService();
     Gallery       = new GalleryService();
     Analytics     = new AnalyticsService();
     WebView       = new WebViewService();
 }
Beispiel #3
0
 public GalleryTests()
 {
     this.InitializeMapper();
     this.InitializeDatabaseAndRepositories();
     this.InitializeFields();
     this.galleryService = new GalleryService(this.galleryRepository);
 }
Beispiel #4
0
        public async Task AllWithNulllId()
        {
            ApplicationDbContext dbContext = new ApplicationDbContext(new DbContextOptionsBuilder <ApplicationDbContext>()
                                                                      .UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString()).Options);
            var service = new GalleryService(new EfDeletableEntityRepository <Pic>(dbContext));

            for (int i = 1; i < 6; i++)
            {
                await service.AddAsync(
                    "http://wwww.test.img" + i,
                    "1");
            }

            int page        = 1;
            int itemPerPage = 3;
            var pics        = service.All <GuestViewModel>(null, itemPerPage, (page - 1) * itemPerPage);
            int count       = 0;

            foreach (var pic in pics)
            {
                count++;
            }

            Assert.Equal(0, count);
        }
Beispiel #5
0
        public IActionResult Index()
        {
            var years = GalleryService.Instance(_options).Years.OrderByDescending(y => y.Year);

            ViewBag.model = years;

            return(View());
        }
Beispiel #6
0
 public ActionResult DeletePhoto(int photoId, string path)
 {
     if (GalleryService.DeletePhoto(photoId))
     {
         DeletePhotoFromServer(path);
     }
     return(View());
 }
Beispiel #7
0
        //编辑相册
        public ActionResult Edit(string Id)
        {
            List <Articles> list = ArticleService.GetArticlesAll();
            Photos          pho  = GalleryService.GetById(Id);

            ViewBag.A = list;
            ViewBag.B = pho;
            return(View());
        }
 public GalleryController(GalleryRepository galleryRepository, GalleryService galleryService, IMapper mapper, FileHelper fileHelper, PaginatedMetaService paginatedMetaService, GalleryImageRepository galleryImageRepository)
 {
     _galleryRepository      = galleryRepository;
     _galleryService         = galleryService;
     _mapper                 = mapper;
     _fileHelper             = fileHelper;
     _paginatedMetaService   = paginatedMetaService;
     _galleryImageRepository = galleryImageRepository;
 }
        public async Task GetImage_Should_Throw_If_No_Image_Found()
        {
            using var context = await this.GetDatabase();

            var mapper         = this.GetMapper();
            var galleryService = new GalleryService(context, null, mapper);


            Assert.Throws <ArgumentException>(() => galleryService.GetImage <ImageApiViewModel>("Incorrect").Id);
        }
Beispiel #10
0
        public void GetPhotos_Should_Return_A_List()
        {
            var galleryRepositoryMock = new Mock <IGalleryRepository>();
            var service = new GalleryService(galleryRepositoryMock.Object);

            galleryRepositoryMock.Setup(x => x.Get()).Returns(_PhotoList);

            var photos = service.GetPhotos();

            Assert.NotNull(photos);
        }
Beispiel #11
0
        public void ShouldCreateSomeGalleries()
        {
            var galleryJson = StubDataLoader.LoadJsonFile("Gallery.json");

            var service = new GalleryService(new MoxiWorksClient(new StubContextClient(galleryJson)));

            var response = service.GetAgentGalleries("FooBarBazGoo", AgentIdType.MoxiWorksagentId, "company_id").Result;

            Assert.IsType <GalleryResults>(response.Item);
            Assert.True(response.Item.Galleries.Count == 1);
        }
Beispiel #12
0
 public ActionResult EditAlbum(EditAlbumViewModel album)
 {
     if (!ModelState.IsValid)
     {
         return(View(album));
     }
     if (GalleryService.EditAlbum(album.ToEntity()))
     {
         return(RedirectToAction("index", "gallery"));
     }
     return(View());
 }
        public async Task GetImage_Should_Return_Correct_Image()
        {
            using var context = await this.GetDatabase();

            var mapper         = this.GetMapper();
            var galleryService = new GalleryService(context, null, mapper);

            var expected = "1";
            var actual   = galleryService.GetImage <ImageApiViewModel>("1").Id;

            Assert.Equal(expected, actual);
        }
Beispiel #14
0
 public ActionResult CreateAlbum(CreateAlbumViewModel album)
 {
     if (!ModelState.IsValid)
     {
         return(View());
     }
     if (GalleryService.CreateAlbum(album.ToEntity()))
     {
         return(RedirectToAction("Index", "Gallery"));
     }
     return(View());
 }
Beispiel #15
0
 public ActionResult Editalbum(int albumId)
 {
     try
     {
         var album = GalleryService.GetById(albumId);
         return(View(new EditAlbumViewModel(album)));
     }
     catch (Exception ex)
     {
         return(Content(ex.Message));
     }
 }
Beispiel #16
0
 public ActionResult Detailsalbum(string url)
 {
     try
     {
         var album = GalleryService.GetByURL(url);
         return(View(new DetailsAlbumViewModel(album)));
     }
     catch (Exception ex)
     {
         return(View(ex.Message));
     }
 }
Beispiel #17
0
        [ValidateInput(false)]//可以提交富文本
        public ActionResult Add(Photos photo)
        {
            int count = GalleryService.AddPhotos(photo);

            if (count >= 1)
            {
                return(Json(new UIResult(true, "新增成功")));
            }
            else
            {
                return(Json(new UIResult(false, "新增失败")));
            }
        }
Beispiel #18
0
        [ValidateInput(false)]//可以提交富文本
        public ActionResult Edit(Photos photo)
        {
            int count = GalleryService.EditPhotos(photo);

            if (count >= 1)
            {
                return(Json(new UIResult(true, "编辑成功")));
            }
            else
            {
                return(Json(new UIResult(false, "编辑失败")));
            }
        }
Beispiel #19
0
        public IActionResult Detail(string id)
        {
            var model = GalleryService.Instance(_options).GetEvent(id);

            if (model == null)
            {
                return(RedirectToAction("Index"));
            }

            ViewBag.model = model;

            return(View());
        }
Beispiel #20
0
        public async Task GetGalleryCountWithNoexistingName()
        {
            ApplicationDbContext dbContext = new ApplicationDbContext(new DbContextOptionsBuilder <ApplicationDbContext>()
                                                                      .UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString()).Options);
            var repository = new EfDeletableEntityRepository <Pic>(dbContext);
            var service    = new GalleryService(repository);
            await service.AddAsync(
                "http://www.test.com",
                "1");

            Assert.Equal(0, service.GetGalleryCount("11"));
            dbContext.Database.EnsureDeleted();
        }
Beispiel #21
0
        public ActionResult DeleteImage(int Imageid)
        {
            string message = "";

            if (GalleryService.DeleteImage(Imageid, out message))
            {
                return(RedirectToAction("Index"));
            }
            else
            {
                return(RedirectToAction("DeleteImage", new { Imageid = Imageid, message = message }));
            }
        }
Beispiel #22
0
        public ActionResult EditImage(Gallery image)
        {
            string message = "";

            if (GalleryService.EditImage(image, out message))
            {
                return(RedirectToAction("Index"));
            }
            else
            {
                return(RedirectToAction("EditImage", new { image = image, message = message }));
            }
        }
        public async Task RemoveImageAsync_Should_Set_IsActual_To_False()
        {
            using var context = await this.GetDatabase();

            var mapper         = this.GetMapper();
            var galleryService = new GalleryService(context, null, mapper);

            await galleryService.RemoveImageAsync("1");

            var expected = false;
            var actual   = (await context.GalleryImages.FirstAsync()).IsActual;

            Assert.Equal(expected, actual);
        }
Beispiel #24
0
        public async Task AddAsyncWithValidlId()
        {
            ApplicationDbContext dbContext = new ApplicationDbContext(new DbContextOptionsBuilder <ApplicationDbContext>()
                                                                      .UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString()).Options);
            var service = new GalleryService(new EfDeletableEntityRepository <Pic>(dbContext));
            await service.AddAsync(
                "http://wwww.test.img",
                "1");

            var pic = await dbContext.Pics.FirstOrDefaultAsync();

            Assert.Equal("http://wwww.test.img", pic.Url);
            Assert.Equal("1", pic.GamingHallId);
            dbContext.Database.EnsureDeleted();
        }
        private GalleryService SetupGalleryService()
        {
            var galleryRepository = new GalleryRepositoryMock();
            var pictureRepository = new PictureRepositoryMock();
            var tagRepository     = new TagRepositoryMock();
            var galleryGenerator  = new GalleryGeneratorFactory(tagRepository, pictureRepository, galleryRepository);
            var mapperConfig      = new MapperConfiguration(mc =>
            {
                mc.AddProfile(new Mappings.AutoMapperGalleryProfile());
            });

            var galleryService = new GalleryService(galleryRepository, galleryGenerator, mapperConfig.CreateMapper());

            return(galleryService);
        }
Beispiel #26
0
        public ActionResult GalleryList(int page, int limit,
                                        string BelongToArticles)
        {
            //获取总条数
            string sql1 = string.Format("select Count(*) from [dbo].[Photos]");

            if (!string.IsNullOrEmpty(BelongToArticles))
            {
                sql1 += string.Format("where BelongToArticles={0}", BelongToArticles);
            }
            int cou = Convert.ToInt32(DBHelper.ExecuteScalar(sql1));

            List <Photos> List = GalleryService.getPhotosPage(page, limit, BelongToArticles);

            return(Json(new { code = 0, msg = "", count = cou, data = List }, JsonRequestBehavior.AllowGet));
        }
Beispiel #27
0
        public ActionResult AddPhoto(int albumId, string photoPath)
        {
            var pathGalleryPhoto = System.Configuration.ConfigurationManager.AppSettings["pathGalleryPhoto"];
            var photo            = new AlbumPhoto()
            {
                AlbumId = albumId,
                Path    = photoPath
            };

            if (GalleryService.SavePhotoInAlbum(photo))
            {
                photo.Path = pathGalleryPhoto + photo.Path;
                return(PartialView("_Photo", photo));
            }
            return(View());
        }
Beispiel #28
0
        public ActionResult DeleteAlbum(int albumId)
        {
            var album = GalleryService.GetById(albumId);

            if (album != null)
            {
                foreach (var photo in album.Photos)
                {
                    DeletePhotoFromServer(photo.Path);
                }
                if (GalleryService.DeleteAlbum(albumId))
                {
                    return(RedirectToAction("index", "gallery"));
                }
            }
            return(View());
        }
Beispiel #29
0
        public async Task DeleteAsyncWithValidId()
        {
            ApplicationDbContext dbContext = new ApplicationDbContext(new DbContextOptionsBuilder <ApplicationDbContext>()
                                                                      .UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString()).Options);
            var service = new GalleryService(new EfDeletableEntityRepository <Pic>(dbContext));
            await service.AddAsync(
                "http://www.test.com",
                "1");

            var pic = await dbContext.Pics.FirstOrDefaultAsync();

            await service.DeleteAsync(pic.Id);

            var result = await dbContext.Pics.Where(x => x.Id == pic.Id).FirstOrDefaultAsync();

            Assert.True(result == null);
            dbContext.Database.EnsureDeleted();
        }
Beispiel #30
0
        static void Main(string[] args)
        {
            Mapper.Initialize(
                cfg =>
            {
                cfg.AddProfile <AutoMapperProfile>();
            });
            Directory.SetCurrentDirectory("../../..");
            using (var db = new HipstagramContext())
            {
                IUserService  service      = new UserService(db);
                IPhotoService photoService = new PhotoService(new HostingEnvironment(), db, Mapper.Instance);
                var           x            = photoService.GetUserPhotos(new User {
                    Id = 1
                }).ToList();

                IGalleryService galleryService = new GalleryService(db, photoService);

                //var gallery = new Gallery { Name = "XD2" };
                var user = new User {
                    Id = 1
                };
                //gallery.Owners = new List<UserGalleries> { new UserGalleries { User = user, Gallery = gallery } };
                //galleryService.AddGallery(user, gallery);
                var galleries = galleryService.GetUserAll(user);
                galleryService.AddPhotos(Mapper.Map <GalleryDto>(galleries.FirstOrDefault()), new PhotoDto {
                    Id = 1
                });
                //photoService.GetFromGallery()
                //////gallery.Photos = new List<GalleryPhotos> {new GalleryPhotos{Gallery = gallery, Photo = userPhotos.First()}};
                ////galleryService.AddGallery(gallery);
                //galleryService.AddPhotos(Mapper.Map<GalleryDto>(new Gallery{Id = 5}), new PhotoDto{Id = 1});
                //var photos = photoService.GetFromGallery(new Gallery { Id = 5 });
                //foreach (Photo photo in photos)
                //{
                //    Console.Write(photo.Title + " " + photo.Description);
                //}
                Console.Write("End");
            }
        }