Example #1
0
        //Add a review to the contentobject. User must have create rights on the repo
        public string AddReview(Review inreview, string pid, string key)
        {
            if (!CheckKey(key))
                return null;

            pid = pid.Replace('_', ':');

            //Get the content object
            vwarDAL.ContentObject co = GetRepo().GetContentObjectById(pid, false);

            //Check permissions
            if (!DoValidate(Security.TransactionType.Access, pid))
            {
                ReleaseRepo();
                return "";
            }

            //Set the user authorized for this transaction to the submitterfor the review
            inreview.Submitter = this.GetUserEmail();

            //Translate into a vwardal review
            vwarDAL.Review r = new vwarDAL.Review();
            r.Text = inreview.ReviewText;
            r.SubmittedBy = inreview.Submitter;
            r.SubmittedDate = DateTime.Now;
            r.Rating = inreview.Rating;
            if (r.Rating < 0) r.Rating = 0;
            if (r.Rating > 5) r.Rating = 5;
            if (r.Text == null) r.Text = "";
            //Add the review
            co.AddReview(r);

            //Commit the changes
            co.CommitChanges();
            ReleaseRepo();
            return "ok";
        }
Example #2
0
        //Get all the reviews for the object. Uses query permissions
        public List<Review> GetReviews(string pid, string key)
        {
            if (!CheckKey(key))
                return null;
            pid = pid.Replace('_', ':');
            //Get the content object
            vwarDAL.ContentObject co = GetRepo().GetContentObjectById(pid, false);

            //Check permissions
            if (!DoValidate(Security.TransactionType.Query, pid))
            {
                ReleaseRepo();
                return null;
            }

            //Setup the return structure
            List<Review> results = new List<Review>();

            //Loop over reviews and add to rreturn structure
            foreach (vwarDAL.Review dr in co.Reviews)
            {
                Review r = new Review();
                r.DateTime = dr.SubmittedDate.ToString();
                r.Rating = dr.Rating;
                r.Submitter = dr.SubmittedBy;
                r.ReviewText = dr.Text;
                results.Add(r);

            }

            //return the reviews
            ReleaseRepo();
            return results;
        }