示例#1
0
        public ProductType(ICategory category, IReview review, IOrder order)
        {
            Name        = "Product";
            Description = "Product fields";

            Field(x => x.ProductId).Description("Product Id");
            Field(x => x.Name).Description("Product name");
            Field(x => x.Description).Description("Product description");
            Field(x => x.Price).Description("Product price");
            Field(x => x.ImagePath).Description("Product image path");

            Field <ProductType>("Category",
                                Description = "Category of product",
                                resolve: context =>
            {
                return(category.GetById(context.Source.CategoryId));
            });
            Field <ListGraphType <ReviewType> >("Reviews",
                                                Description = "Reviews of product",
                                                resolve: context =>
            {
                return(review.GetReviewsByProductId(context.Source.ProductId));
            });
            Field <ListGraphType <OrderType> >("Orders",
                                               Description = "Orders of product",
                                               resolve: context =>
            {
                return(order.GetOrdersByProductId(context.Source.ProductId));
            });
        }
示例#2
0
 public ReviewViewModel(IReview review)
 {
     Title      = review.Title;
     Text       = review.Text;
     Rating     = review.Rating;
     DateOfPost = review.DateOfPost;
 }
        public Result AddReview(IReview review)
        {
            Result result = new Result()
            {
                IsSuccessful = true
            };

            try
            {
                using (var ctx = new RestaurantReviewContext())
                {
                    Review rev = review as Review;
                    rev.ReviewID = Guid.NewGuid().ToString();

                    ctx.Reviews.Add(rev);
                    ctx.SaveChanges();
                }
            }
            catch (Exception e)
            {
                result.IsSuccessful = false;
                result.Message      = e.Message;
            }

            return(result);
        }
 public CustomerReviewController(IReviewNotification reviewNotification, IReview review, IReviewAction reviewAction, IReviewKind reviewKind)
 {
     _review             = review;
     _reviewNotification = reviewNotification;
     _reviewAction       = reviewAction;
     _reviewKind         = reviewKind;
 }
示例#5
0
 public DetailModel(UserManager <User> userManager,
                    TuplaContext context,
                    IGame db,
                    IGamePicture picdb,
                    IGameTag dbgametag,
                    IPlatform platformdb,
                    IPlatformOfGame gamePlatformdb,
                    ITag dbTag,
                    IWishList wishdb,
                    ITransaction transdb,
                    IOrderDetail orderdetaildb,
                    IReview reviewdb,
                    ICustomerPicture userpicdb)
 {
     this.userManager    = userManager;
     this.context        = context;
     this.db             = db;
     this.picdb          = picdb;
     this.dbgametag      = dbgametag;
     this.platformdb     = platformdb;
     this.gamePlatformdb = gamePlatformdb;
     this.dbTag          = dbTag;
     this.wishdb         = wishdb;
     this.transdb        = transdb;
     this.orderdetaildb  = orderdetaildb;
     this.reviewdb       = reviewdb;
     this.userpicdb      = userpicdb;
 }
示例#6
0
        public UserType(IReview review, IOrder order, IDataLoaderContextAccessor accessor)
        {
            Name        = "User";
            Description = "User fields";

            Field(x => x.UserId).Description("User Id");
            Field(x => x.FullName).Description("User name and surname");

            Field <ListGraphType <ReviewType>, IEnumerable <Review> >()
            .Name("Reviews")
            .Description("User reviews")
            .ResolveAsync(ctx =>
            {
                var ordersLoader = accessor.Context.GetOrAddCollectionBatchLoader <int, Review>("GetReviewsByUserId", review.GetReviewsByUserIdAsync);
                return(ordersLoader.LoadAsync(ctx.Source.UserId));
            });

            Field <ListGraphType <OrderType>, IEnumerable <Order> >()
            .Name("Orders")
            .Description("User orders")
            .ResolveAsync(ctx =>
            {
                var ordersLoader = accessor.Context.GetOrAddCollectionBatchLoader <int, Order>("GetOrdersByUserId", order.GetOrdersByUserIdAsync);

                return(ordersLoader.LoadAsync(ctx.Source.UserId));
            });
        }
示例#7
0
        public Book(string title, string author, IReview review)
        {
            Title  = title;
            Author = author;

            this.review = review;
        }
示例#8
0
 public ReviewViewModel(IReview review, string reviewWriterFullName)
 {
     Title                = review.Title;
     Text                 = review.Text;
     Rating               = review.Rating;
     DateOfPost           = review.DateOfPost;
     ReviewWriterFullName = reviewWriterFullName;
 }
示例#9
0
 public UssdController(IOrganisationAsync organisation, ICustomer customer, ITeamMember teamMember, IReviewNotification reviewNotification, IReview review)
 {
     _organisation       = organisation;
     _customer           = customer;
     _teamMember         = teamMember;
     _reviewNotification = reviewNotification;
     _review             = review;
 }
示例#10
0
 public Review(IReview review)
 {
     if (review == null)
     {
         throw new ArgumentNullException(nameof(review));
     }
     _review = review;
 }
 public TextOfferSimple(ITravelAgency agency, int n)
 {
     trip   = agency.CreateTrip();
     review = new IReview[n];
     for (int i = 0; i < n; i++)
     {
         review[i] = agency.CreateReview();
     }
 }
示例#12
0
        public void Review_WhenSet_RaisesPropertyChanged()
        {
            IReview newReview = AReview.Build();

            var test = new ReviewChecklistItem();

            test.AssertThatChangeNotificationIsRaisedBy(x => x.Review).
            When(() => test.Review = newReview);
            Assert.Same(newReview, test.Review);
        }
示例#13
0
        public ITripOffer CreateTemporaryTripOffer()
        {
            ITravelAgency travelAgency = TravelAgencies[Rd.Next(0, TravelAgencies.Count)];

            IReview[] reviews = new IReview[NumberOfReviews];
            for (int i = 0; i < NumberOfReviews; ++i)
            {
                reviews[i] = travelAgency.CreateReview();
            }
            return(new TextTemporaryTripOffer(travelAgency.CreateTrip(), ViewLimit, reviews));
        }
示例#14
0
        public override IOffer PrepareOffer(ITravelAgency travelAgency)
        {
            IReview[] reviews = new IReview[reviewsAmount];

            for (int i = 0; i < reviewsAmount; i++)
            {
                reviews[i] = travelAgency.CreateReview();
            }

            return(new TextOffer(travelAgency.CreateTrip(), reviews));
        }
示例#15
0
        public void CreateOffer(ITravelAgency travelAgency, int descriptionsCount, bool timed, int expireTime)
        {
            ITrip trip = travelAgency.CreateTrip();

            IReview[] reviews = new IReview[descriptionsCount];
            for (int i = 0; i < descriptionsCount; i++)
            {
                reviews[i] = travelAgency.CreateReview();
            }

            Offers.Add(new TextOffer(trip, reviews, timed, expireTime));
        }
示例#16
0
        /// <summary>
        /// コンストラクタ
        /// </summary>
        /// <param name="reviewModel"></param>
        public Review(IReview reviewModel)
        {
            // 同じ名前のフィールドをコピー
            this.CopyFieldsFrom(reviewModel);

            // 指摘をコピー
            foreach (var issueModel in reviewModel.Issues)
            {
                var issue = new Issue(issueModel);
                Issues.Add(issue);
            }
        }
示例#17
0
        public void CreateReview(IReview _review)
        {
            var review = new ReviewModel
            {
                ReviewId = _review.ReviewId,
                Review   = _review.Review,
                Rating   = _review.Rating,
                MovieId  = _review.MovieId,
                UserId   = _review.UserId
            };

            reviewContext.CreateReview(review);
        }
示例#18
0
        public void CreateReview(IReview review)
        {
            var _review = new Review()
            {
                ID        = review.ID,
                EventID   = review.ID,
                AccountID = review.AccountID,
                Rating    = review.Rating,
                Message   = review.Message
            };

            ReviewDataBaseHandler.CreateReview(_review);
        }
示例#19
0
 public AdminController(IDonation donation, ILoanDonor loanDonor, IRecurringDonation recurringDonation,
                        ILoan loan, IContact contact, IUserProfile userProfile, ICause cause, IReview review, IVolunteer volunteer, IConfiguration config, IHttpContextAccessor accessor)
 {
     _cause             = cause;
     _recurringdonation = recurringDonation;
     _loan        = loan;
     _loandonor   = loanDonor;
     _volunteer   = volunteer;
     _donation    = donation;
     _contact     = contact;
     _review      = review;
     _userprofile = userProfile;
     _config      = config;
     _accessor    = accessor;
 }
        public Result AddReview(IReview review)
        {
            string filePath = ConfigurationManager.AppSettings["ReviewsXMLFilePath"];
            Result result   = new Result()
            {
                IsSuccessful = true
            };
            List <Review> reviews = new List <Review>();

            //Get a list of existing restaurants from disk
            IRestaurant[] restaurants = GetRestaurantsByCity(string.Empty);

            //Check if the restaurant ID is valid
            if (!isRestaurantIDValid(review.RestaurantID, restaurants))
            {
                result.IsSuccessful = false;
                result.Message      = Constants.ErrorMessageInvalidRestaurantID;
                return(result);
            }

            //If the restaurant ID is valid, get a list of reviews from disk
            try
            {
                reviews = deserializeFromDisk <List <Review> >(filePath);
            }
            catch (Exception e)
            {
                result.IsSuccessful = false;
                result.Message      = e.Message;
            }

            //Generate new ID for the review
            review.ReviewID = Guid.NewGuid().ToString();
            reviews.Add((Review)review);

            //Save all reviews to disk
            try
            {
                result = serializeToDisk <List <Review> >(reviews, filePath);
            }
            catch (Exception e)
            {
                result.IsSuccessful = false;
                result.Message      = e.Message;
            }

            return(result);
        }
示例#21
0
        public bool Update(int id, IReview review)
        {
            using (var connection = Database.GetConnection())
            {
                connection.Open();
                var cmd = connection.CreateCommand();

                cmd.CommandText = ReviewSqlServer.ReqPut;

                cmd.Parameters.AddWithValue($"@{ReviewSqlServer.ColId}", id);
                cmd.Parameters.AddWithValue($"@{ReviewSqlServer.ColStars}", review.Stars);
                cmd.Parameters.AddWithValue($"@{ReviewSqlServer.ColDescriptionReview}", review.DescriptionReview);

                return(cmd.ExecuteNonQuery() > 0);
            }
        }
示例#22
0
        public void Create(IReview review)
        {
            if (review == null)
            {
                throw new ArgumentNullException("review");
            }

            var errors = _reviewValidator.Validate(review);

            if (errors?.Any() == true)
            {
                throw new Exception(string.Join(Environment.NewLine, errors));
            }

            _reviewRepository.Create(review);
        }
        //Update in CRUD
        public void UpdateReview(IReview R1)
        {
            using (MySqlConnection conn = new MySqlConnection(connectionString))
            {
                string query = "UPDATE review SET EventID = @EventID, AccountID = @AccountID, Rating=@Rating,Message=@Message WHERE ID=@ID; ";
                using (MySqlCommand command = new MySqlCommand(query, conn))
                {
                    command.Parameters.AddWithValue("@ID", R1.ID);
                    command.Parameters.AddWithValue("@EventID", R1.EventID);
                    command.Parameters.AddWithValue("@AccountID", R1.AccountID);
                    command.Parameters.AddWithValue("@Rating", R1.Rating);
                    command.Parameters.AddWithValue("@Message", R1.Message);

                    command.ExecuteNonQuery();
                }
            }
        }
        //Create in CRUD
        public void CreateReview(IReview R1)
        {
            using (MySqlConnection conn = new MySqlConnection(connectionString))
            {
                string query = "INSERT INTO review VALUES(@EventID, @AccountID,@Rating,@Message); ";

                using (MySqlCommand command = new MySqlCommand(query, conn))
                {
                    command.Parameters.AddWithValue("@EventID", R1.EventID);
                    command.Parameters.AddWithValue("@AccountID", R1.AccountID);
                    command.Parameters.AddWithValue("@Rating", R1.Rating);
                    command.Parameters.AddWithValue("@Message", R1.Message);

                    command.ExecuteNonQuery();
                }
            }
        }
示例#25
0
        //Create in CRUD
        public void CreateReview(IReview review)
        {
            _connection.SqlConnection.Open();
            string query = "INSERT INTO `review` (`ReviewId`, `Review`, `Rating`, `MovieId`, `UserId`) VALUES (@ReviewId, @Review, @Rating, @MovieId, @UserId); ";

            using (MySqlCommand command = new MySqlCommand(query, _connection.SqlConnection))
            {
                command.Parameters.AddWithValue("@ReviewId", review.ReviewId);
                command.Parameters.AddWithValue("@Review", review.Review);
                command.Parameters.AddWithValue("@Rating", review.Rating);
                command.Parameters.AddWithValue("@MovieId", review.MovieId);
                command.Parameters.AddWithValue("@UserId", review.UserId);

                command.ExecuteNonQuery();
            }
            _connection.SqlConnection.Close();
        }
示例#26
0
        public void AddReviewTest()
        {
            IReview review = _container.Resolve <IReview>();

            review.RestaurantID = "cb3174cb-d626-499f-b14c-9a87af082c37";
            review.Reviewer     = "countcyrillus";
            review.Rating       = "4";
            review.Comment      = "This is a test";

            Result result = _dataAccessLayer.AddReview(review);

            Assert.IsTrue(result.IsSuccessful);
            Assert.IsNull(result.Message);

            review.RestaurantID = "146bb41b-a648-41bd-8999-b0b94ed2bfc";
            result = _dataAccessLayer.AddReview(review);
            Assert.IsFalse(result.IsSuccessful);
            Assert.IsNotNull(result.Message);
        }
示例#27
0
        public IReview Create(int uservId, int itemId, IReview review)
        {
            using (var connection = Database.GetConnection())
            {
                connection.Open();
                var cmd = connection.CreateCommand();
                cmd.CommandText = ReviewSqlServer.ReqCreate;

                cmd.Parameters.AddWithValue($"@{ReviewSqlServer.ColStars}", review.Stars);
                cmd.Parameters.AddWithValue($"@{ReviewSqlServer.ColTitle}", review.Title);
                cmd.Parameters.AddWithValue($"@{ReviewSqlServer.ColDescriptionReview}", review.DescriptionReview);
                cmd.Parameters.AddWithValue($"@{ReviewSqlServer.ColItemId}", itemId);
                cmd.Parameters.AddWithValue($"@{ReviewSqlServer.ColUserId}", uservId);

                review.Id = (int)cmd.ExecuteScalar();
            }

            return(review);
        }
示例#28
0
        public ProductType(ICategory category, IReview review, IOrder order, IDataLoaderContextAccessor accessor)
        {
            Name        = "Product";
            Description = "Product fields";

            Field(x => x.ProductId).Description("Product Id");
            Field(x => x.Name).Description("Product name");
            Field(x => x.Description).Description("Product description");
            Field(x => x.Price).Description("Product price");
            Field(x => x.ImagePath).Description("Product image path");

            Field <ProductType>("Category",
                                Description = "Category of product",
                                resolve: context =>
            {
                return(category.GetByIdAsync(context.Source.CategoryId));
            });


            Field <ListGraphType <ReviewType>, Review>()
            .Name("Reviews")
            .Description("Reviews of product")
            .ResolveAsync(context =>
            {
                var loader = accessor.Context.GetOrAddBatchLoader <int, Review>("GetReviewsByProductId", async(IEnumerable <int> ids) => { return(await review.GetReviewsByProductIdAsync(ids)); });
                return(loader.LoadAsync(context.Source.ProductId));
                //var loader = accessor.Context.GetOrAddBatchLoader<int, Review>("GetReviewsByProductId", review.GetReviewsByProductIdAsync);
                //return loader.LoadAsync(context.Source.ProductId);
            });

            Field <OrderType, Order>()
            .Name("Orders")
            .Description("Orders of product")
            .ResolveAsync(context =>
            {
                var loader = accessor.Context.GetOrAddBatchLoader <int, Order>("GetOrdersByProductId", async(IEnumerable <int> ids) => { return(await order.GetOrdersByProductIdAsync(ids)); });
                return(loader.LoadAsync(context.Source.ProductId));
                //var loader = accessor.Context.GetOrAddBatchLoader<int, Order>("GetOrdersByProductId", order.GetOrdersByProductIdAsync);
                //return loader.LoadAsync(context.Source.ProductId);
            });
        }
示例#29
0
        public UserType(IReview review, IOrder order)
        {
            Name        = "User";
            Description = "User fields";

            Field(x => x.UserId).Description("User Id");
            Field(x => x.FullName).Description("User name and surname");

            Field <ListGraphType <ReviewType> >("Reviews",
                                                Description = "User reviews",
                                                resolve: context =>
            {
                return(review.GetReviewsByUserId(context.Source.UserId));
            });
            Field <ListGraphType <OrderType> >("Orders",
                                               Description = "User orders",
                                               resolve: context =>
            {
                return(review.GetReviewsByUserId(context.Source.UserId));
            });
        }
示例#30
0
        public IReview SaveReview(IReview review)
        {
            if (review == null)
            {
                throw new ArgumentNullException(nameof(review), "Review is required");
            }

            var reviewEntity = (Review)review;

            AuditHelper.SetAuditFieldsOnSave(reviewEntity,
                                             _dateTimeService.UtcNow(),
                                             _securityService.CurrentUserId());

            ValidateReview(reviewEntity);

            AddReviewToContext(reviewEntity);

            _context.SaveChanges();

            return(reviewEntity);
        }
示例#31
0
 /// <summary>
 /// Add entity
 /// </summary>
 public async Task<int> AddAsync(IReview review)
 {
     try
     {
         return await repository.AddAsync<ReviewEntity>
             (Mapper.Map<ReviewEntity>(review));
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
示例#32
0
        /// <summary>
        /// Update IReview
        /// </summary>
        /// <param name="review">IReview</param>
        /// <returns>IReview</returns>
        public async Task<IReview> UpdateIReviewAsync(IReview review)
        {
            try
            {
                IUnitOfWork uow = repository.CreateUnitOfWork();
                ReviewEntity result = await uow.UpdateWithAttachAsync<ReviewEntity>(AutoMapper.Mapper.Map<ReviewEntity>(review));
                await uow.CommitAsync();

                return AutoMapper.Mapper.Map<IReview>(result);

            }
            catch (Exception ex)
            {
                
                throw ex;
            }
        }
示例#33
0
        /// <summary>
        /// Adds review and updates game with score
        /// </summary>
        /// <param name="review">Review</param>
        /// <returns>Review</returns>
        public async Task<IReview> AddIReviewAsync(IReview review)
        {
            try
            {
                IUnitOfWork uow = repository.CreateUnitOfWork();
                
                ReviewEntity result =  await uow.AddAsync<ReviewEntity>(Mapper.Map<ReviewEntity>(review));
                await uow.CommitAsync();

                return Mapper.Map<IReview>(result);

            }
            catch (Exception ex)
            {
                
                throw ex;
            }
        }