public ActionResult DeleteConfirmed(string id)
        {
            Forum_Comment forum_Comment = db.Forum_Comments.Find(id);

            db.Forum_Comments.Remove(forum_Comment);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Beispiel #2
0
        public ActionResult AddComment(FormCollection f, int Id_Post)
        {
            Forum_Comment fc = new Forum_Comment();

            fc.Id_Forum_Post = Id_Post;
            fc.Id_User       = int.Parse(Session["LogedUserID"].ToString());
            fc.Content       = f.Get("txtContent").ToString();
            db.Forum_Comment.Add(fc);
            db.SaveChanges();
            return(RedirectToAction("DetailPost", "Forum", new { Id_Post = Id_Post, page = 1 }));
        }
 public ActionResult Edit([Bind(Include = "ID,Forum_ID,NIN,Comment")] Forum_Comment forum_Comment)
 {
     if (ModelState.IsValid)
     {
         db.Entry(forum_Comment).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.NIN      = new SelectList(db.Demographics, "NIN", "ImagePath", forum_Comment.NIN);
     ViewBag.Forum_ID = new SelectList(db.Forum_Headers, "ID", "Topic", forum_Comment.Forum_ID);
     return(View(forum_Comment));
 }
        // GET: Forum_Comment/Details/5
        public ActionResult Details(string id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Forum_Comment forum_Comment = db.Forum_Comments.Find(id);

            if (forum_Comment == null)
            {
                return(HttpNotFound());
            }
            return(View(forum_Comment));
        }
        // GET: Forum_Comment/Edit/5
        public ActionResult Edit(string id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Forum_Comment forum_Comment = db.Forum_Comments.Find(id);

            if (forum_Comment == null)
            {
                return(HttpNotFound());
            }
            ViewBag.NIN      = new SelectList(db.Demographics, "NIN", "ImagePath", forum_Comment.NIN);
            ViewBag.Forum_ID = new SelectList(db.Forum_Headers, "ID", "Topic", forum_Comment.Forum_ID);
            return(View(forum_Comment));
        }
        public ActionResult Create([Bind(Include = "ID,Forum_ID,NIN,Comment")] Forum_Comment forum_Comment)
        {
            var    query = db.Forum_Comments.Count() + 1;
            string temp  = "FC-" + query;
            bool   exist = false;

            try
            {
                var search = db.Forum_Comments.Where(c => c.ID == temp).Single();
                exist = true;
            }
            catch
            {
                exist = false;
            }
            if (exist)
            {
                var all      = db.Forum_Comments.ToList();
                var fcomment = all.Last();
                fcomment.ID = "DIET-" + DataModels.DataProcess.NextNumber(fcomment.ID);
            }
            else
            {
                forum_Comment.ID = temp;
            }
            if (ModelState.IsValid)
            {
                db.Forum_Comments.Add(forum_Comment);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.NIN      = new SelectList(db.Demographics, "NIN", "ImagePath", forum_Comment.NIN);
            ViewBag.Forum_ID = new SelectList(db.Forum_Headers, "ID", "Topic", forum_Comment.Forum_ID);
            return(View(forum_Comment));
        }