public static List<CommentSection> GetAllCommentSectionsForComment(Comment aComment)
        {
            PortugalVillasContext _db = new PortugalVillasContext();
            List<CommentSection> theCommentSections = new List<CommentSection>();

            theCommentSections = _db.CommentSections.Where(x => x.CommentID == aComment.CommentID).ToList();

            return theCommentSections;
        }
        public void Create(FormCollection theFormCollection)
        {

            Comment comment = new Comment();

            comment.WhenCreated = DateTime.Now;
            comment.Username = theFormCollection["Username"];
            comment.StarRating = 1;
            comment.PropertyID = Convert.ToInt64(theFormCollection["PropertyID"]);

            try
            {
                var date = DateTime.ParseExact(theFormCollection["StartdateOfStay"].ToString(), "dd/MM/yyyy", CultureInfo.InvariantCulture);
                comment.StartdateOfStay = date;
            }
            catch (Exception ex)
            {
                
                
            }
            if (theFormCollection["StarRating"].ToString() != "")
            {
                comment.StarRating = Convert.ToInt32(theFormCollection["StarRating"]);
            }
            
            comment.Text = theFormCollection["Text"];


            try
            {
                if (ModelState.IsValid)
                {
                    comment.Approved = true;
                    //comment.WhenCreated = DateTime.Now;

                    db.Comments.Add(comment);
                    db.SaveChanges();


                }
            }
            catch (DbEntityValidationException dataValidationException)
            {
                //do nothing                
            }
            catch (Exception ex)
            {
                throw ex;
            }

            string RootURL = Request.Url.Authority;
            RootURL += "/Home/FullPropertyResult?PropertyID=" + comment.PropertyID;

            Response.Redirect("http://" + RootURL);
           
        }
 public ActionResult Edit(Comment comment)
 {
     if (ModelState.IsValid)
     {
         db.Entry(comment).State = EntityState.Modified;
         db.SaveChanges();
         return RedirectToAction("Index");
     }
     ViewBag.PropertyID = new SelectList(db.Properties, "PropertyID", "LegacyReference", comment.PropertyID);
     return View(comment);
 }