public void GetAll_Should_Return_4_Castles() { var sut = new ReviewRepository(); var result = sut.GetAll(); Assert.Equal(4, result.Count); }
public ActionResult Game() { ViewBag.Message = "Game Specific Reviews."; var reviewRepository = new ReviewRepository(); var ReviewList = reviewRepository.GetAll("Game"); return(View(ReviewList)); }
public ActionResult reviews() { ReviewRepository reviewRepository = new ReviewRepository(); var reviews = reviewRepository.GetAll(); ViewBag.reviews = reviews; return(View()); }
public virtual async Task <Review> GetCurrentReview() { Review review = null; var reviewId = Request.Cookies["reviewId"]; if (!string.IsNullOrEmpty(reviewId)) { review = await ReviewRepository.GetAll().Include(o => o.ReviewRounds).Where(o => o.Id == int.Parse(reviewId)).SingleOrDefaultAsync(); } return(review); }
/// <summary> /// 提交评审及修改评审活动页 /// </summary> /// <returns></returns> public async Task <IActionResult> ReviewRoundSubmit(int?data) { var matchInstance = await GetCurrentMatchInstance(); ViewData["matchInstance"] = matchInstance; //获取当前赛事下的所有没有建立评审轮次的评选活动 var reviews = await ReviewRepository.GetAll().Where(o => o.MatchInstanceId == matchInstance.Id && o.ReviewRounds.Count == 0).OrderBy(o => o.ReviewName).ToListAsync(); ViewBag.Reviews = reviews; return(View()); }
public ActionResult RemoveSave(int id) { var reviewRepository = new ReviewRepository(); // check if default hidden value is passed -- means empty form if (id == 0) { TempData["Error"] = "Unable to process, no ID was specified"; var ReviewList = reviewRepository.GetAll(); return(View("Remove", ReviewList)); } if (!ModelState.IsValid) { TempData["Error"] = "Unable to process, no ID was specified"; var ReviewList = reviewRepository.GetAll(); return(View("Remove")); } reviewRepository.Delete(id); TempData["Success"] = "Successfully Deleted Review " + id; return(View("Index")); }
public void GetAll_Returns_All() { underTest.Create(new Review() { Content = "Baby" }); underTest.Create(new Review() { Content = "Baby" }); var all = underTest.GetAll(); Assert.Equal(2, all.Count()); }
public void TestIRepository_Create_SingleParentEntity() { // Arrange int authorsToInsert = 1; int booksPerAuthor = 20; int reviewsPerBook = 2; List <Author> authors = new List <Author>(GetAuthors(authorsToInsert, booksPerAuthor, reviewsPerBook)); // Act AuthorRepository.Create(authors); List <Author> createdAuthors = AuthorRepository.GetAll(); List <Book> createdBooks = BookRepository.GetAll(); List <Review> createdReviews = ReviewRepository.GetAll(); // Assert Assert.AreEqual(authorsToInsert, createdAuthors.Count); Assert.AreEqual(authorsToInsert * booksPerAuthor, createdBooks.Count); Assert.AreEqual(authorsToInsert * booksPerAuthor * reviewsPerBook, createdReviews.Count); }
public virtual async Task BringOutFinalReview(int[] projectIds) { if (await ProjectRepository.CountAsync(o => projectIds.Contains(o.Id) && !o.IsInFinalReview) > 0) { throw new UserFriendlyException("项目已经被移出终评"); } //所有终评中的项目 var reviews = await ReviewRepository.GetAll().Where(o => o.ReviewType == ReviewType.Finish) .ToListAsync(); var finalReviewProjects = reviews.SelectMany(o => o.ReviewProjects).Select(o => o.Id).Distinct(); if (projectIds.Count(o => finalReviewProjects.Contains(o)) > 0) { throw new UserFriendlyException("无法将终评中的项目移出终评"); } //已经是终评中的项目无法取消终评 //if(await ProjectRepository.CountAsync(o=>projectIds.Contains(o.Id) && o.ProjectStatus == ProjectStatus.FinalReviewing) > 0) //{ // throw new UserFriendlyException("无法将终评中的项目移出终评"); //} var projects = await ProjectRepository.GetAll().Where(o => projectIds.Contains(o.Id)).ToListAsync(); foreach (var project in projects) { project.IsInFinalReview = false; //获取项目之前的项目状态 var traceLogs = await ProjectTraceLogRepository.GetAll().Where(o => o.ProjectId == project.Id).ToListAsync(); if (traceLogs.Count > 2) { //最后一项记录保存的是项目的当前状态,故再往上取一个记录 var lastTraceLog = traceLogs[traceLogs.Count - 2]; project.ProjectStatus = lastTraceLog.TargetStatus; //更改项目状态 await ProjectManager.TraceLog(project.Id, "移出终评", project.ProjectStatus); } await CacheManager.GetCache <int, object>("ProjectResultCache").RemoveAsync(project.Id); } }
public void GetAllReturnsReviewsList(IQueryable <Review> data) { //Arrange var mockSet = new Mock <DbSet <Review> >(); mockSet.As <IQueryable <Review> >().Setup(m => m.Provider).Returns(data.Provider); mockSet.As <IQueryable <Review> >().Setup(m => m.Expression).Returns(data.Expression); mockSet.As <IQueryable <Review> >().Setup(m => m.ElementType).Returns(data.ElementType); mockSet.As <IQueryable <Review> >().Setup(m => m.GetEnumerator()).Returns(data.GetEnumerator); var mock = new Mock <RentContext>(); mock.Setup(a => a.Reviews).Returns(mockSet.Object); //Act var repository = new ReviewRepository(mock.Object); var result = repository.GetAll(); //Assert Assert.That(result, Is.TypeOf(typeof(List <Review>))); }
public void GetAll_Returns_All() { underTest.Create(new Review() { Content = "I love this pony", ReviewerName = "Carl", Rating = 5.0, ProductId = 1, }); underTest.Create(new Review() { Content = "This pony can Fly", ReviewerName = "Amelia", Rating = 4.6, ProductId = 1, }); var all = underTest.GetAll(); Assert.Equal(6, all.Count()); }
public ActionResult ReviewList() { return(View(reviewrepo.GetAll())); }
public GraphQL4BooksQuery( BookRepository bookRepository, UserRepository userRepository, ReviewRepository reviewRepository, AuthorRepository authorRepository) { Field <ListGraphType <BookType> >( "books", resolve: context => bookRepository.GetAll() ); //FieldAsync<ListGraphType<BookType>>( // "books", // resolve: async context => await bookRepository.GetAll() //); Field <BookType>( "book", arguments: new QueryArguments(new QueryArgument <NonNullGraphType <IdGraphType> > { Name = "id" }), resolve: context => { var id = context.GetArgument <Guid>("id"); return(bookRepository.GetById(id)); } ); Field <ListGraphType <UserType> >( "users", resolve: context => userRepository.GetAll() ); Field <UserType>( "user", arguments: new QueryArguments(new QueryArgument <NonNullGraphType <IdGraphType> > { Name = "id" }), resolve: context => { var id = context.GetArgument <Guid>("id"); return(userRepository.GetById(id)); } ); Field <ListGraphType <ReviewType> >( "reviews", resolve: context => reviewRepository.GetAll() ); Field <ReviewType>( "review", arguments: new QueryArguments(new QueryArgument <NonNullGraphType <IdGraphType> > { Name = "id" }), resolve: context => { var id = context.GetArgument <Guid>("id"); return(reviewRepository.GetById(id)); } ); Field <ListGraphType <AuthorType> >( "authors", resolve: context => authorRepository.GetAll() ); Field <AuthorType>( "author", arguments: new QueryArguments(new QueryArgument <NonNullGraphType <IdGraphType> > { Name = "id" }), resolve: context => { var id = context.GetArgument <Guid>("id"); return(authorRepository.GetById(id)); } ); }
public ActionResult ReviewListbyProduct(int id) { return(View(reviewrepo.GetAll().Where(x => x.ProductID == id))); }
public async Task <List <Review> > Get() { // Getting all records from the Review table return(await _repository.GetAll()); }
public void GetAll_Single_SeededReview() { var review = _reviewRepositorySUT.GetAll().Single(i => i.Id == Seed.Review1.Id); Assert.Equal(ReviewMapper.MapToListModel(Seed.Review1), review, ReviewListModel.ReviewListModelComparer); }
public List <Review> GetAllReviews() { return(revRepo.GetAll().ToList()); }
public async Task <List <Review> > GetAll() { return(await _repository.GetAll()); }
public List <Review> getAllReviews() { return(_reviewRepository.GetAll()); }
public ActionResult Manage() { return(View(reviewRepository.GetAll().ToList())); }
public void TestGetAllReviewsOk() { List <Review> reviewsToReturn = new List <Review>() { new Review() { Id = 1, Comment = "Horrible", Score = 3, BookingId = 2 }, new Review() { Id = 2, Comment = "Bueni", BookingId = 1, Score = 5 }, }; _context.Add(new Accommodation() { Name = "b", Id = 1 }); _context.Add(new Booking { Id = 1, AccommodationId = 1, BookingHistory = new List <BookingStage>(), CheckIn = DateTime.Now, CheckOut = DateTime.Now.AddDays(3), GuestId = 2, Guests = new List <Guest>(), HeadGuest = new Tourist() { Email = "*****@*****.**" }, TotalPrice = 35 }); _context.Add(new Booking { Id = 2, AccommodationId = 1, BookingHistory = new List <BookingStage>(), CheckIn = DateTime.Now, CheckOut = DateTime.Now.AddDays(3), GuestId = 2, Guests = new List <Guest>(), HeadGuest = new Tourist() { Email = "*****@*****.**" }, TotalPrice = 35 }); reviewsToReturn.ForEach(r => _context.Add(r)); _context.SaveChanges(); var repository = new ReviewRepository(_context); var result = repository.GetAll(); Assert.IsTrue(reviewsToReturn.SequenceEqual(result)); }