Esempio n. 1
0
        public CommentBase CommentEdit2(CommentEdit newComment)
        {
            var o = ds.Comments.Include("location").SingleOrDefault
                        (c => c.CommentId == newComment.CommentId && c.UserName == HttpContext.Current.User.Identity.Name);

            // addComment.UserName = HttpContext.Current.User.Identity.Name;

            if (o == null)
            {
                return(null);
            }
            else
            {
                ds.Entry(o).CurrentValues.SetValues(newComment);
                ds.SaveChanges();
                return(mapper.Map <CommentBase>(o));
            }
        }
Esempio n. 2
0
        public ActionResult Edit(int?id, CommentEdit newComment, int locId)
        {
            if (!HttpContext.User.Identity.IsAuthenticated)
            {
                return(RedirectToAction("Login", "Account"));
            }
            if (!ModelState.IsValid)
            {
                return(RedirectToAction("Edit", new { id = newComment }));
            }
            if (id.GetValueOrDefault() != newComment.CommentId)
            {
                return(RedirectToAction("PubLocationDetails", "Location"));
            }
            var editedComment = m.CommentEdit2(newComment);
            var locationNum   = new locationB
            {
                LocationId = locId
            };

            return(RedirectToAction("PubLocationDetails", "Location", new { id = locId }));
        }