Exemplo n.º 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";
        }
Exemplo n.º 2
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="r"></param>
 /// <returns></returns>
 public bool AddReview(vwarDAL.Review r)
 {
     mParentRepo.InsertReview(r.Rating, r.Text, r.SubmittedBy, this.PID);
     return(true);
 }