public void ShouldRetrieveAPicture() { var id = Guid.NewGuid(); var mockStorage = new Mock <IStorageContext>(); mockStorage.Setup(s => s.Query <Picture>(StorageAccountConfiguration.PicturesTable)).Returns(() => { var result = new List <Picture>(); result.Add(new Picture() { Id = id }); result.Add(new Picture() { Id = Guid.NewGuid() }); return(result.AsQueryable()); }); var repository = new PictureRepository(mockStorage.Object); var picture = repository.Get(id); Assert.AreEqual(picture.Id, id); }
public static PictureRepository GetPictureRepository(IUnitOfWork unitOfWork) { var repository = new PictureRepository(); repository.UnitOfWork = unitOfWork; return(repository); }
public static PictureRepository GetPictureRepository() { var repository = new PictureRepository(); repository.UnitOfWork = GetUnitOfWork(); return(repository); }
public IActionResult Picture(int Id) { PictureRepository pictureRepository = new PictureRepository(_connectionString); Picture p = pictureRepository.GetPictureById(Id); return(View(p)); }
public IActionResult Index() { PictureRepository pictureRepository = new PictureRepository(_connectionString); List <Picture> pictures = pictureRepository.GetPictures(); return(View(pictures)); }
public IActionResult AddPicture(Picture p) { PictureRepository picture = new PictureRepository(_connectionString); picture.AddPicture(p); return(Redirect("/Home/Index")); }
/// <summary> /// Gets the loaded picture binary depending on picture storage settings /// </summary> /// <param name="picture">Picture</param> /// <param name="fromDb">Load from database; otherwise, from file system</param> /// <returns>Picture binary</returns> public virtual byte[] LoadPictureBinary(Picture picture, bool fromDb) { if (picture == null) { throw new ArgumentNullException("picture"); } byte[] result = null; if (fromDb) { if (picture.PictureBinary != null) { result = picture.PictureBinary; } else { result = new PictureRepository().PictureBinary(picture.Id); } } else { result = LoadPictureFromFile(picture.Id, picture.MimeType); } return(result); }
public void ShouldSaveAPicture() { var picture = new Picture() { Name = "picture1", Description = "desc of picture1", Tags = string.Empty }; var image = new byte[] { 1, 2, 3 }; var mockStorage = new Mock <IStorageContext>(); mockStorage.Setup(s => s.SaveBlob(It.IsAny <string>(), It.IsAny <byte[]>(), It.IsAny <string>())).Returns(() => { return("http://foo"); }); var repository = new PictureRepository(mockStorage.Object); picture = repository.Save(picture, image); Assert.AreNotEqual(picture.Id, Guid.Empty); Assert.AreEqual(picture.Url, new Uri("http://foo")); mockStorage.Verify(s => s.SaveBlob(It.IsAny <string>(), It.IsAny <byte[]>(), It.IsAny <string>()), Times.Once()); mockStorage.Verify(s => s.AddEntity(It.IsAny <Picture>(), StorageAccountConfiguration.PicturesTable), Times.Once()); mockStorage.Verify(s => s.AddEntities(It.IsAny <IEnumerable <PictureTag> >(), StorageAccountConfiguration.PictureTagTable), Times.Once()); }
public PictureRepository GetPictureRepository() { if (pictureRepository == null) { pictureRepository = new PictureRepository(); } return pictureRepository; }
public UnitOfWork(ImgSpotContext context) { _context = context; Users = new UserRepository(_context); Pictures = new PictureRepository(_context); Comments = new CommentRepository(_context); Likes = new LikeRepository(_context); }
public IList <Picture> GetLastestPictures() { using (PictureRepository repo = new PictureRepository()) { var pictures = repo.GetLastestPictures(1, 50); return(pictures); } }
public PictureRepository GetPictureRepository() { if (pictureRepository == null) { pictureRepository = new PictureRepository(); } return(pictureRepository); }
public StudentRepositoryTest() { _context = new Mock <DatabaseEntities>(); _mySetStudent = new Mock <DbSet <STUDENT> >(); _mySetPicture = new Mock <DbSet <PICTURE> >(); _repo = new StudentRepository(_context.Object); _picture = new PictureRepository(_context.Object); }
public PictureController(IConfiguration config, PictureRepository pictureRepository, UserManager <User> userManager, ILogger <PictureController> logger) { _config = config; _pictureRepository = pictureRepository; _storageAccount = CloudStorageAccount.Parse(config.GetConnectionString("BlobStorage")); _userManager = userManager; _logger = logger; }
public IActionResult GetLikes(int Id) { Likes l = new Likes(); PictureRepository picture = new PictureRepository(_connectionString); l.number = picture.GetLikesCount(Id); return(Json(l)); }
public DataLayerService() { config = new LocalConfig(); pictureRepository = new PictureRepository(config); foodRepository = new FoodRepository(config); userRepository = new UserRepository(config); restaurantRepository = new RestaurantRepository(config); }
public IList <Picture> SearchPictures(string name, string familyName, string series, string artist) { using (PictureRepository repo = new PictureRepository()) { IList <Picture> pictures = repo.SearchPictures(name, familyName, series, artist); return(pictures); } }
public SearchController(UserManager <User> userManager, IConfiguration config, PictureRepository pictureRepository, SearchRepository searchRepository) { _userManager = userManager; _config = config; _storageAccount = CloudStorageAccount.Parse(config.GetConnectionString("BlobStorage")); _pictureRepository = pictureRepository; _searchRepository = searchRepository; }
public DataLayerService() { config = new LocalConfig(); pictureRepository = new PictureRepository(config); placeRepositiry = new PlaceRepositiry(config); userRepository = new UserRepository(config); }
private void IntializaPictureRepository() { var mockValidator = new Mock <IHostingEnvironment>(); var contentRootPath = Directory.GetCurrentDirectory(); mockValidator.Setup(x => x.ContentRootPath).Returns(contentRootPath); _pictureRepository = new PictureRepository(mockValidator.Object); }
public EventFactory() { eRepository = new EventRepository(new Entities()); lRepository = new LocationRepository(new Entities()); oRepository = new OrganisationRepository(new Entities()); teRepository = new TypeEventRepository(new Entities()); pRepository = new PictureRepository(new Entities()); edRepository = new EventDateRepository(new Entities()); }
public UnitOfWork(AdvertContext context) { this.context = context; CommentRepository = new CommentRepository(context); RatingRepository = new RatingRepository(context); RealEstateRepository = new RealEstateRepository(context); UserRepository = new UserRepository(context); PictureRepository = new PictureRepository(context); }
public async Task GetAllPicturesAsync() { //Arrage var yapartContext = new YapartStoreContext(); var pictures = new PictureRepository(yapartContext); //Act var result = await pictures.GetAll().ToListAsync(); //Assert var aa = 0; }
public IEnumerable <Picture> Get() { List <Picture> pictures; using (IRepository <Picture> picturesRepository = new PictureRepository(_context)) { pictures = picturesRepository.GetAll().ToList(); } return(pictures); }
public async Task <bool> Add(Picture picture) { bool result; using (IRepository <Picture> picturesRepository = new PictureRepository(_context)) { result = await picturesRepository.Insert(picture); } return(result); }
public Picture Get(int id) { Picture picture; using (IRepository <Picture> pictureRepository = new PictureRepository(_context)) { picture = pictureRepository.Get(id); } return(picture); }
public MainViewModel(ShopNetworkContext dbCont) { _subGroupRepository = new SubGroupRepository(dbCont); _groupRepository = new GroupRepository(dbCont); _personRepository = new PersonRepository(dbCont); _pictureRepository = new PictureRepository(dbCont); _adminRepository = new AdminRepository(dbCont); _discountRepository = new DiscountRepository(dbCont); _productRepository = new ProductRepository(dbCont); _newsRepository = new NewsRepository(dbCont); _cartRepository = new CartRepository(dbCont); }
public ActionResult UserPicture(HttpPostedFileBase file) { if (file != null && file.ContentLength > 0) { var filename = Path.GetFileName(file.FileName); var pathname = Path.Combine(Server.MapPath("~/Content/Images"), filename); //Saves the picture in Images file.SaveAs(pathname); PictureRepository.UploadPicture(User.Identity.Name, filename); } return(RedirectToAction("Profile", "User")); }
public async Task <bool> BanPicture(int id) { using (IRepository <Picture> picturesRepository = new PictureRepository(_context)) { var pic = picturesRepository.GetById(id); if (pic == null) { return(false); } pic.Removed = true; return(await picturesRepository.Update(pic)); } }
public Respone AddProduct(ProductCreateViewModel product, string username) { User current = UserRepository.GetItemByID(username); if (current == null) { return new Respone { IsDone = false, Message = "Only signed users can add products" } } ; else { try { product.Product.PublicationDate = DateTime.Now; product.Product.UploadedByUser = current; if (Validator.TryValidateObject(product.Files, new ValidationContext(product.Files), null)) { ProductRepository.InsertItem(product.Product); PictureRepository.InsertItem(new Picture() { IsMainPicture = true, ProductID = product.Product, Image = PicturesSerializationAdapter.Serialize(product.Files.MainImage) }); PictureRepository.InsertItem(new Picture() { ProductID = product.Product, Image = PicturesSerializationAdapter.Serialize(product.Files.Image2) }); PictureRepository.InsertItem(new Picture() { ProductID = product.Product, Image = PicturesSerializationAdapter.Serialize(product.Files.Image3) }); Save(); return(new Respone { IsDone = true }); } else { throw new Exception("Invalid files"); } } catch (Exception e) { Rollback(); return(new Respone { IsDone = false, Message = e.Message }); } } }
protected IAdminCarsService GetService(ApplicationDbContext dbContext) { var carRepository = new CarRepository(dbContext); var carOptionsRepository = new CarOptionRepository(dbContext); var adminDeleteService = new AdminCommonDeleteService(dbContext); var pictureRepository = new PictureRepository(dbContext); var service = new AdminCarsService( carRepository, carOptionsRepository, pictureRepository, adminDeleteService); return(service); }
public static PictureRepository GetPictureRepository() { var repository = new PictureRepository(); repository.UnitOfWork = GetUnitOfWork(); return repository; }
public static PictureRepository GetPictureRepository(IUnitOfWork unitOfWork) { var repository = new PictureRepository(); repository.UnitOfWork = unitOfWork; return repository; }
public RepositoryRegistry() { For<ICredentialRepository>() .Use(factory => { return new CredentialRepository(factory.GetInstance<Entities>()); }); For<IProfileRepository>() .Use(factory => { var repository = new ProfileRepository(factory.GetInstance<Entities>()); return repository; }); For<IProfileActivityRepository>() .Use(factory => { var repository = new ProfileActivityRepository(factory.GetInstance<Entities>()); return repository; }); For<IGrunkerRepository>() .Use(factory => { var repository = new GrunkerRepository(factory.GetInstance<Entities>()); return repository; }); For<IActivityTypeRepository>() .Use(factory => { var repository = new ActivityTypeRepository(factory.GetInstance<Entities>()); return repository; }); For<IPictureRepository>() .Use(factory => { var repository = new PictureRepository(factory.GetInstance<Entities>()); return repository; }); For<IGenreRepository>() .Use(factory => { var repository = new GenreRepository(factory.GetInstance<Entities>()); return repository; }); For<IArtistRepository>() .Use(factory => { var repository = new ArtistRepository(factory.GetInstance<Entities>()); return repository; }); For<IAlbumRepository>() .Use(factory => { var repository = new AlbumRepository(factory.GetInstance<Entities>()); return repository; }); For<IPurchaseRepository>() .Use(factory => { var repository = new PurchaseRepository(factory.GetInstance<Entities>()); return repository; }); For<IReviewRepository>() .Use(factory => { var repository = new ReviewRepository(factory.GetInstance<Entities>()); return repository; }); For<IReviewLinkRepository>() .Use(factory => { var repository = new ReviewLinkRepository(factory.GetInstance<Entities>()); return repository; }); For<IStoreDetailsRepository>() .Use(factory => { var repository = new StoreDetailsRepository(HttpContext.Current.Server.MapPath("~/App_Data/storedetails.xml")); return repository; }); For<IStaticTextRepository>() .Use(factory => { var repository = new StaticTextRepository(factory.GetInstance<Entities>()); return repository; }); }
public void PictureRepository_can_query_List_from_datasource() { //Arrange var picRepo = new PictureRepository(_unitOfWorkMock.Object); //Action var picList = picRepo.GetAllInOrder(0, HomePageViewModel.TOP_SLIDE_PIC_COUNT); //Assertions _unitOfWorkMock.Verify(uow => uow.GetAll<Picture, int>(p => p.OrdinalIndex, true, 0, HomePageViewModel.TOP_SLIDE_PIC_COUNT)); Assert.That(picList.Count == 1); Assert.AreEqual(picList[0], _testPic); }
public void The_PictureRepository_can_query_next_random_picture() { //Arrange var picRepo = new PictureRepository(_unitOfWorkMock.Object); //Act var randomPicture = picRepo.GetNextRandomPicture(_referencePictureIDs); //Assert _unitOfWorkMock.Verify(uow => uow.GetRandom<Picture>(It.Is<Expression<Func<Picture, bool>>>(e => ReferencePictureIDsDoesNotContainRandomPictureID(e))) , Times.Once()); Assert.AreEqual(_randomPicture, randomPicture); }