Exemplo n.º 1
0
        public PartialViewResult Chwinometer(Guid ReportID)
        {
            var reportChwinometer = new Rating();

            reportChwinometer.ReportID = ReportID;

            return PartialView("_Chwinometer", reportChwinometer);
        }
Exemplo n.º 2
0
 /// <summary>
 /// Create a new Rating object.
 /// </summary>
 /// <param name="ratingID">Initial value of the RatingID property.</param>
 /// <param name="reportID">Initial value of the ReportID property.</param>
 /// <param name="rank">Initial value of the Rank property.</param>
 /// <param name="userID">Initial value of the UserID property.</param>
 public static Rating CreateRating(global::System.Guid ratingID, global::System.Guid reportID, global::System.Int32 rank, global::System.String userID)
 {
     Rating rating = new Rating();
     rating.RatingID = ratingID;
     rating.ReportID = reportID;
     rating.Rank = rank;
     rating.UserID = userID;
     return rating;
 }
Exemplo n.º 3
0
 /// <summary>
 /// Deprecated Method for adding a new object to the Ratings EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToRatings(Rating rating)
 {
     base.AddObject("Ratings", rating);
 }
Exemplo n.º 4
0
        public ActionResult Rate(Rating model)
        {
            var db = new ChwinockEntities();

            // Check to see if User has already rated this report
            if (db.Ratings.Any(x => x.UserID == model.UserID && x.ReportID == model.ReportID))
            {
                var targetRating = db.Ratings.Single(x => x.UserID == model.UserID && x.ReportID == model.ReportID);

                targetRating.Rank = model.Rank;
            }
            else
            {
                var newRating = new Rating();

                newRating.RatingID = Guid.NewGuid();
                newRating.ReportID = model.ReportID;
                newRating.UserID = model.UserID;
                newRating.Rank = model.Rank;

                db.Ratings.AddObject(newRating);
            }

            db.SaveChanges();

            return RedirectToAction("Index");
        }