public void Add(PendingReview review)
 {
     var reviewElement = new XElement ("review");
     foreach (var property in typeof(PendingReview).GetProperties()) {
         var propertyName = property.Name.ToLower ();
         if (propertyName != "tags" && propertyName != "id")
             reviewElement.Add (new XElement (propertyName) { Value = (string)property.GetValue (review) });
         else if (propertyName == "tags")
             reviewElement.Add (new XElement ("tags") { Value = String.Join (",", review.Tags) });
         else
             reviewElement.Add (new XElement ("id") { Value = ((int)property.GetValue(review)).ToString() });
     }
     _database.Root.Add (reviewElement);
     _database.Save (_dbPath);
 }
Exemple #2
0
 public ActionResult AddReview([Bind(Include = "Form")]ReviewCreatorModel model)
 {
     if (ModelState.IsValid) {
         var author = TempData.ContainsKey ("author") ? (string)TempData ["author"] : "";
         var authorId = TempData.ContainsKey ("authorId") ? (string)TempData ["authorId"] : "";
         var message = new StringBuilder ();
         message.AppendLine (model.Form.Title);
         message.Append (model.Form.Description);
         var review = new PendingReview () {
             Id = pendingRepository.GetNextId (),
             Title = model.Form.Title,
             Description = model.Form.Description,
             Tags = model.Form.Tags.Split (','),
             Author = author,
             AuthorId = authorId,
             Category = model.Form.Category,
             //PostId = postId
         };
         pendingRepository.Add (review);
         TempData.Remove ("author");
         TempData.Remove ("authorId");
     }
     return RedirectToAction("Success");
 }