コード例 #1
0
        public ActionResult DeleteConfirmed(int id)
        {
            AComment aComment = db.AComments.Find(id);

            db.AComments.Remove(aComment);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
コード例 #2
0
        public async Task <JsonResult> AddComment(int id, [FromBody] AComment value)
        {
            var day = await _context.conctereDays.FindAsync(id);

            _context.Entry(day).State = EntityState.Modified;
            day.services_comment      = value.comment;
            await _context.SaveChangesAsync();

            return(new JsonResult(_responce.Return_Responce(System.Net.HttpStatusCode.OK, day,
                                                            null)));
        }
コード例 #3
0
 public ActionResult Edit([Bind(Include = "Id,Description,Comdate,AnswerId,UserId")] AComment aComment)
 {
     if (ModelState.IsValid)
     {
         db.Entry(aComment).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.AnswerId = new SelectList(db.Answers, "Id", "Description", aComment.AnswerId);
     ViewBag.UserId   = new SelectList(db.ApplicationUsers, "Id", "Email", aComment.UserId);
     return(View(aComment));
 }
コード例 #4
0
        public ActionResult Create([Bind(Include = "Id,Description")] AComment aComment, int?id)
        {
            aComment.UserId = this.User.Identity.GetUserId();
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            aComment.AnswerId = id;
            aComment.Comdate  = DateTime.Now;
            db.AComments.Add(aComment);
            db.SaveChanges();

            return(RedirectToAction("Details/", "Questions", new { id = id.ToString(), viewtype = "extended" }));
        }
コード例 #5
0
        // GET: AComments/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            AComment aComment = db.AComments.Find(id);

            if (aComment == null)
            {
                return(HttpNotFound());
            }
            return(View(aComment));
        }
コード例 #6
0
        // GET: Posts/Details/5
        public ActionResult Details(int?id)
        {
            ApplicationDbContext Context = new ApplicationDbContext();

            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Post            post     = db.Posts.Find(id);
            List <AComment> comments = new List <AComment>();

            foreach (var item in post.Comments)
            {
                AComment aComment = new AComment
                {
                    CommentId      = item.CommentId,
                    CommentContent = item.CommentContent,
                    CommentDate    = item.CommentDate,
                    PostId         = item.PostId
                };
                if (item.UserId != null)
                {
                    aComment.UserName = Context.Users.Find(item.UserId).UserName;
                }
                else
                {
                    aComment.UserName = "******";
                }
                comments.Add(aComment);
            }
            comments.Reverse();

            APost postComments = new APost
            {
                PostId      = post.PostId,
                PostHeading = post.PostHeading,
                UserId      = post.UserId,
                UserName    = Context.Users.Find(post.UserId).UserName,
                PostDate    = post.PostDate,
                PostContent = post.PostContent,
                Comments    = comments
            };

            if (post == null)
            {
                return(HttpNotFound());
            }
            return(View(postComments));
        }
コード例 #7
0
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            AComment aComment = db.AComments.Find(id);

            if (aComment == null)
            {
                return(HttpNotFound());
            }
            ViewBag.AnswerId = new SelectList(db.Answers, "Id", "Description", aComment.AnswerId);

            return(View(aComment));
        }