Beispiel #1
0
        public async Task <MProductReview> AddProductReviewAsync(MProductReview review)
        {
            const string sql = "INSERT INTO dbo.ProductReviews (Title, Body, Rating, ProductId, UserId) " +
                               "OUTPUT INSERTED.Id, INSERTED.Title, INSERTED.Body, INSERTED.Rating, INSERTED.ProductId, INSERTED.UserId, " +
                               "INSERTED.LastUpdate, INSERTED.CreateDate " +
                               "VALUES (@Title, @Body, @Rating, @ProductId, @UserId);";

            return(await GetProductReviewAsync(await connection.ExecuteScalarAsync <int>(sql, review)));
        }
Beispiel #2
0
        public async Task <IActionResult> PutProductReviewAsync([FromBody] MProductReview review)
        {
            if (!User.IsInRole(RoleConstants.AdminRoleId) && !await productsRepository.IsProductReviewOwnerAsync(review.Id, int.Parse(User.Identity.Name)))
            {
                return(BadRequest());
            }

            await productsRepository.UpdateProductReviewAsync(review);

            return(Ok());
        }
Beispiel #3
0
        public async Task <IActionResult> PostProductReviewAsync([FromBody] MProductReview review)
        {
            review.UserId = int.Parse(User.Identity.Name);
            if (!await productsRepository.CanReviewProductAsync(review.ProductId, review.UserId))
            {
                return(BadRequest());
            }

            review = await productsRepository.AddProductReviewAsync(review);

            await discordService.SendReviewAsync(review, Request.Headers["Origin"]);

            return(Ok(review));
        }
Beispiel #4
0
        protected override async Task OnInitializedAsync()
        {
            var response = await HttpClient.GetAsync("api/products/" + ProductId);

            statusCode = response.StatusCode;
            if (statusCode == HttpStatusCode.OK)
            {
                Product = await response.Content.ReadFromJsonAsync <MProduct>();

                if (SteamAuth.IsAuthenticated)
                {
                    Review = Product.Reviews.FirstOrDefault(x => x.UserId == SteamAuth.User.Id);
                    Product.Reviews.Remove(Review);
                }
            }

            await CartService.ReloadCartAsync();
        }
Beispiel #5
0
        public async Task SendReviewAsync(MProductReview review, string baseUrl)
        {
            var product = await productsRepository.GetProductAsync(review.ProductId, 0);

            var eb = new EmbedBuilder();

            eb.WithColor(Color.Blue);
            eb.WithAuthor(product.Name, baseUrl + "/api/images/" + product.ImageId, baseUrl + "/products/" + product.Id);
            eb.WithFooter(review.User.Name);
            eb.WithCurrentTimestamp();

            string stars = "";

            for (int i = 1; i <= review.Rating; i++)
            {
                stars += ":star:";
            }
            eb.WithTitle(stars);
            eb.AddField(review.Title, review.Body);

            SendEmbed(config["SendNewReviewWebhookUrl"], eb.Build());
        }
Beispiel #6
0
        private async Task DeleteReviewAsync(MProductReview review)
        {
            await HttpClient.DeleteAsync("api/products/reviews/" + review.Id);

            Product.Reviews.Remove(review);
        }
Beispiel #7
0
 private void OnReviewChanged(MProductReview review)
 {
     Review = review;
 }
 public async Task DeleteReviewAsync(MProductReview review)
 {
     await OnDeleteReview.InvokeAsync(review);
 }
 public async Task AskDeleteReviewAsync(MProductReview review)
 {
     await DeleteReviewConfirm.ShowAsync(review);
 }
Beispiel #10
0
 public async Task UpdateProductReviewAsync(MProductReview review)
 {
     const string sql = "UPDATE dbo.ProductReviews SET Title = @Title, Body = @Body, Rating = @Rating, " +
                        "LastUpdate = SYSDATETIME() WHERE Id = @Id;";
     await connection.ExecuteAsync(sql, review);
 }