public ProductReviewViewModel(Product SelectedProduct) { AddProductReviewCommand = new AddProductReviewCommand(this); UpdateProductReviewCommand = new UpdateProductReviewCommand(this); RemoveProductReviewCommand = new RemoveProductReviewCommand(this); AddedReview = new ProductReview(); this.ProductReviewModel = new ProductReviewModel(SelectedProduct); Reviews = new ObservableCollection <ProductReview>(ProductReviewModel.ProductReviews); }
public ProductReview AddProductReview(AddProductReviewCommand newProductReview) { using (var connection = new SqlConnection(_connectionString)) { connection.Open(); var sql = @"INSERT INTO [dbo].[ProductReview] ([Comment] ,[Rating] ,[ProductId] ,[UserName]) output inserted.* VALUES (@Comment ,@Rating ,@ProductId ,@UserName)"; return(connection.QueryFirst <ProductReview>(sql, newProductReview)); } }
public void Create(AddProductReviewCommand newProductReview) { var repo = new ProductReviewRepository(); repo.AddProductReview(newProductReview); }