public IEnumerable <ProductReviewView> AddProductReview(ProductReviewView productReviewView) { if (User.Identity.IsAuthenticated) { productReviewView.AspNetUserId = User.Identity.GetUserId(); _ProductService.AddProductReview(productReviewView); } return(_ProductService.GetProductReviews(productReviewView.ProductId)); }
public void AddProductReview(ProductReviewView productReviewView) { var productReview = AutoMapper.Mapper.Map <ProductReviewView, ProductReview>(productReviewView); using (var onlineShopContext = new OnlineShopWebEntities()) { productReview.ReviewDate = DateTime.Now; onlineShopContext.ProductReview.Add(productReview); onlineShopContext.SaveChanges(); } }