Пример #1
0
        public IHttpActionResult PostNewComment(tComment comment)
        {
retryId:
            string commentID = new Utilities().GenerateCoupon(5);

            if (db.tComments.Any(a => a.CommentId == commentID))
            {
                goto retryId;
            }

            comment.DateCreated = DateTime.Now;
            comment.DateUpdated = DateTime.Now;
            comment.CommentId   = commentID;
            var newComment = db.tComments.Add(comment);

            db.SaveChanges();
            var newCommentObj = db.tComments.Where(w => w.recNo == newComment.recNo).Select(ss => new
            {
                ss.CommentId,
                ss.DateCreated,
                ss.DateUpdated,
                ss.Comment,
                ss.PostId,
                ss.UserId,
                Name     = db.tBusinessEntities.Any(b => b.UserId == ss.UserId) ? db.tBusinessEntities.FirstOrDefault(f => f.UserId == ss.UserId).BusinessEntityName : db.tPersonInfoes.Where(p => p.UserId == ss.UserId).Select(sss => new { Name = sss.Firstname + " " + (sss.Middlename != null ? sss.Middlename.Substring(0, 1) + ". " : "") + sss.Lastname }).FirstOrDefault().Name,
                UserType = db.tBusinessEntities.Any(b => b.UserId == ss.UserId) ? 1 : 0
            }).FirstOrDefault();

            context.Clients.All.newComment(newCommentObj);

            return(Json(newComment));
        }
Пример #2
0
        public ActionResult DeleteConfirmed(int id)
        {
            tComment tcomment = db.tComment.Find(id);

            db.tComment.Remove(tcomment);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Пример #3
0
        //
        // GET: /c/Details/5

        public ActionResult Details(int id = 0)
        {
            tComment tcomment = db.tComment.Find(id);

            if (tcomment == null)
            {
                return(HttpNotFound());
            }
            return(View(tcomment));
        }
Пример #4
0
 public ActionResult Edit(tComment tcomment)
 {
     if (ModelState.IsValid)
     {
         db.Entry(tcomment).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.news_ids = new SelectList(db.tNews, "news_id", "title", tcomment.news_ids);
     return(View(tcomment));
 }
Пример #5
0
        public ActionResult Edit(int id = 0)
        {
            tComment tcomment = db.tComment.Find(id);

            if (tcomment == null)
            {
                return(HttpNotFound());
            }
            ViewBag.news_ids = new SelectList(db.tNews, "news_id", "title", tcomment.news_ids);
            return(View(tcomment));
        }
Пример #6
0
        public PartialViewResult comm(int id)
        {
            tComment c = new tComment();

            c.news_ids = id;

            //db.tComment.Add(tcomment);
            //db.SaveChanges();
            //}
            return(PartialView("_comm", c));
            // return View(quess.ToPagedList(pageNumber, pageSize));
        }
Пример #7
0
        /// <summary>
        /// Saves the new comment.
        /// </summary>
        /// <param name="commentDto">The comment dto.</param>
        /// <returns></returns>
        public CommentDTO SaveNewComment(CommentDTO commentDto)
        {
            commentDto.CreatedAt = DateTime.Now;
            tComment comment = Mapper.Map <tComment>(commentDto);

            using (DMSDataBaseEntities context = new DMSDataBaseEntities())
            {
                context.tComments.Add(comment);
                context.SaveChanges();
            }

            return(commentDto);
        }
Пример #8
0
        //<---------------------------------新增留言---------------------------->
        public JsonResult CreateComment(int MemberID, string Main, int ArticleID)
        {
            tComment list = new tComment()
            {
                MemberID  = MemberID,
                Main      = Main,
                ArticleID = ArticleID,
                UpTime    = DateTime.Now,
            };

            tc.create(list);

            return(Json(tc.getAll().LastOrDefault(t => t.No > 0).No, JsonRequestBehavior.AllowGet));
        }
        public ActionResult r回覆(C回覆 y, tComment p)
        {
            send(y);
            //ViewBag.kk = "傳送成功";
            dbJoutaEntities db = new dbJoutaEntities();
            tComment        A  = db.tComment.FirstOrDefault(m => m.fID == p.fID);

            if (A != null)
            {
                A.f意見狀態 = "已回覆";
                db.SaveChanges();
            }
            return(RedirectToAction("List"));
        }
Пример #10
0
        public ActionResult r回覆(int?id)
        {
            if (id == null)
            {
                RedirectToAction("List");
            }

            dbJoutaEntities db = new dbJoutaEntities();
            tComment        x  = new tComment();

            x = db.tComment.FirstOrDefault(m => m.fID == id);

            return(View(x));
        }
Пример #11
0
        public ActionResult Create(tComment tcomment, int?id)
        {
            if (ModelState.IsValid)
            {
                string ip = Request.ServerVariables["HTTP_X_FORWARDED_FOR"] ?? Request.ServerVariables["REMOTE_ADDR"];
                tcomment.http_posted  = ip;
                tcomment.addedcomment = DateTime.Now;
                db.tComment.Add(tcomment);
                db.SaveChanges();
                return(RedirectToAction("post", "n", new { id = tcomment.news_ids }));
            }

            ViewBag.news_ids = new SelectList(db.tNews, "news_id", "title", tcomment.news_ids == id);
            return(View(tcomment));
        }
Пример #12
0
        public ActionResult d刪除(int?id)
        {
            if (id == null)
            {
                RedirectToAction("List");
            }

            tComment        x  = new tComment();
            dbJoutaEntities db = new dbJoutaEntities();

            x = db.tComment.FirstOrDefault(m => m.fID == id);
            db.tComment.Remove(x);
            db.SaveChanges();

            return(RedirectToAction("List"));
        }
Пример #13
0
        public ActionResult New(C回覆 y)
        {
            dbJoutaEntities db = new dbJoutaEntities();
            tComment        x  = new tComment();

            x.f標題   = Request.Form["f標題"];
            x.f意見   = Request.Form["f意見"];
            x.f性別   = Request.Form["f性別"];
            x.f意見類型 = Request.Form["f意見類型"];
            x.f聯絡人  = Request.Form["f聯絡人"];
            x.f電子郵件 = Request.Form["f電子郵件"];
            x.f電話   = Request.Form["f電話"];
            x.f意見時間 = DateTime.Now.ToString();
            x.f意見狀態 = "未回覆";
            db.tComment.Add(x);
            db.SaveChanges();
            string message = "傳送成功";

            ViewBag.ll = message;
            return(View());
        }
Пример #14
0
        public ActionResult Contact(tComment comment, HttpPostedFileBase file)
        {
            if (file != null)
            {
                if (file.ContentLength > 0)
                {
                    fileName = Path.GetFileName(file.FileName);
                    var path = Path.Combine(Server.MapPath("~/images"), fileName);
                    file.SaveAs(path);
                }
            }
            else
            {
                fileName = "cc4.png";
            }

            comment.CommentDate = DateTime.Now;
            comment.Image       = fileName;
            db.tComments.Add(comment);
            db.SaveChanges();
            var latestComment = db.tComments.OrderByDescending(m => m.CommentDate).FirstOrDefault();

            return(View(latestComment));
        }