public EditReviewInputModel(ProductRatingViewModel productRatingViewModel, string text, string productId, string commentId, bool isParentComment, int commentCounter) { this.ProductRatingViewModel = productRatingViewModel; this.Text = text; this.ProductId = productId; this.CommentId = commentId; this.IsParrentComment = isParentComment; this.CommentCounter = commentCounter; }
public bool AddProductRating(ProductRatingViewModel model) { try { _log4net.Info("Rating has been successfully assigned to the product."); return(_prodRepo.AddProductRating(model)); } catch (Exception e) { _log4net.Error("Error in getting product details"); throw e; } }
public IActionResult AddProductRating(ProductRatingViewModel model) { var res = prodProvider.AddProductRating(model); _log4net.Info("method execution in controller completed"); if (res == false) { _log4net.Info("method returns a null value"); return(NotFound()); } _log4net.Info("rating " + model.Rating + " for the product with id=" + model.ProdId + " is assigned"); return(Ok(res)); }
public bool AddProductRating(ProductRatingViewModel model) { try { _log4net.Info("Getting product details for product id " + model.ProdId); Product p = items.FirstOrDefault(x => x.Id == model.ProdId); p.Rating = model.Rating; return(true); } catch (Exception e) { _log4net.Info("No product found with the given product id " + e.Message); return(false); } }
public IHttpActionResult GetAvarage(int id) { if (!db.Products.Any(p => p.Id == id)) { return(NotFound()); } var response = new ProductRatingViewModel(); response.ProductId = id; try { response.AvarageRating = db.ProductRatings.Where(p => p.ProductId == id).Average(p => p.Rating); } catch { response.AvarageRating = 0; } return(Ok(response)); }