public PartialViewResult HighestRatedItem() { List<Rating> ratings = new ProductClient().GetHighlyRatedItem().ToList(); Product p; Rating r = new Rating(); foreach (Rating rate in ratings) { r = rate; } p = new ProductClient().GetProductByID(r.ProductID); ViewBag.Rating = r.Rating1; return PartialView("_highestRatedItem", p); }
/// <summary> /// Create a new Rating object. /// </summary> /// <param name="accountID">Initial value of the AccountID property.</param> /// <param name="productID">Initial value of the ProductID property.</param> /// <param name="rating1">Initial value of the Rating1 property.</param> public static Rating CreateRating(global::System.Int32 accountID, global::System.Int32 productID, global::System.Int32 rating1) { Rating rating = new Rating(); rating.AccountID = accountID; rating.ProductID = productID; rating.Rating1 = rating1; return rating; }
/// <summary> /// Deprecated Method for adding a new object to the Rating EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToRating(Rating rating) { base.AddObject("Rating", rating); }
public ActionResult PostComment(CommentModel model, int pID) { try { if (Session["accountID"] != null) { Rating rating = new Rating(); Rating tempR = new ProductClient().GetRatingByAccountAndProduct((int)Session["accountID"], pID); if (tempR == null) { rating.ProductID = pID; rating.AccountID = (int)Session["accountID"]; rating.Rating1 = model.rating; Comment comment = new Comment(); comment.AccountID = (int)Session["accountID"]; comment.ProductID = pID; comment.Comment1 = model.commnet; new ProductCommentClient().AddComment(comment); new ProductClient().AddRating(rating); return RedirectToAction("PurchaseHistory"); } else { ViewBag.Error = "You already posted a rating for this product."; return View("PostComment", model); } } else { return RedirectToAction("Login", "Login"); } } catch (Exception e) { ViewBag.Error = "An error has occured."; return View("PostComment", model); } }
public JsonResult UpdateProductRating(string productID, int rating) { if (rating < 0) { rating = 0; } else if (rating > 5) { rating = 5; } Rating r = new ProductServ.WCFProductClient().GetRating(new Guid(productID),@User.Identity.Name); if (r != null) { r.Rating1 = rating; new ProductServ.WCFProductClient().UpdateProductRating(r); } else { r = new Rating(); r.ProductID = new Guid(productID); r.Username = @User.Identity.Name; r.Rating1 = rating; new ProductServ.WCFProductClient().AddProductRating(r); } return Json("Success"); }
/// <summary> /// Create a new Rating object. /// </summary> /// <param name="username">Initial value of the Username property.</param> /// <param name="productID">Initial value of the ProductID property.</param> /// <param name="rating1">Initial value of the Rating1 property.</param> public static Rating CreateRating(global::System.String username, global::System.Guid productID, global::System.Int32 rating1) { Rating rating = new Rating(); rating.Username = username; rating.ProductID = productID; rating.Rating1 = rating1; return rating; }