Example #1
0
        public ActionResult WriteComment(long RealEstateID, string comment)
        {
            try
            {
                RealEstateComment aComment = new RealEstateComment()
                {
                    CommentContent = comment,
                    CommentDate    = DateTime.Now,
                    CommentTitle   = "Comment",
                    Username       = Utilities.GetLoggedInUser.UserName,
                    RealEstateID   = RealEstateID,
                    IsSpam         = false
                };

                db.RealEstateComments.Add(aComment);
                db.SaveChanges();

                return(RedirectToAction("Details", "Home", new { id = RealEstateID }));
            }
            catch (Exception ex)
            {
                ViewBag.ErrorMessage = ex.ToString();
                return(View("Error"));
            }
        }
Example #2
0
        public ActionResult DeleteComment(long id)
        {
            RealEstateComment comment = db.RealEstateComments.Find(id);

            db.RealEstateComments.Remove(comment);
            db.SaveChanges();
            return(RedirectToAction("SpamComment"));
        }