Esempio n. 1
0
 public async Task <ActionResult> Comments(ContentComments model, int IDcontent, int IDpage, string Username)
 {
     using (ZavrsniEFentities db = new ZavrsniEFentities())
     {
         if (model.UserComment == null)
         {
             return(Content("The comment cannot be empty!", "text/html"));
         }
         var user     = User.Identity.GetUserName();
         var userInfo = (from u in db.User
                         where u.Username == user
                         select u);
         var newComment = db.ContentComment.Create();
         newComment.IDcontent = IDcontent;
         newComment.IDuser    = userInfo.FirstOrDefault().IDuser;
         newComment.Comment   = model.UserComment;
         newComment.Timestamp = DateTime.Now;
         db.ContentComment.Add(newComment);
         db.SaveChanges();
     }
     return(Content("The comment was successfully added!", "text/html"));
 }
Esempio n. 2
0
        public ActionResult ArticleComments()
        {
            int totalRecords;
            const int pageSize = 10;
            var model = new ContentComments();

            if (string.IsNullOrEmpty(Request.QueryString[
                SiteEnums.QueryStringNames.pg.ToString()]))
            {
                totalRecords = model.GetCommentsPageWise(1, pageSize);
            }
            else
            {
                int pageNumber = Convert.ToInt32(Request.QueryString[
                    SiteEnums.QueryStringNames.pg.ToString()]);

                totalRecords = model.GetCommentsPageWise(pageNumber, pageSize);
            }

            ViewBag.PageCount = (totalRecords + pageSize - 1)/pageSize;

            return View(model);
        }
Esempio n. 3
0
        public bool CreateContentComment(CommentDetails comment)
        {
            // Make sure input is not null
            this.CheckNotNull(() => new { comment });

            try
            {
                var contentComment = new ContentComments();
                Mapper.Map(comment, contentComment);

                contentComment.IsDeleted       = false;
                contentComment.CommentDatetime = DateTime.UtcNow;

                _contentCommentsRepository.Add(contentComment);
                _contentCommentsRepository.SaveChanges();
                return(true);
            }
            catch (Exception)
            {
                // TODO: Add exception handling logic here.
            }

            return(false);
        }
Esempio n. 4
0
        public ActionResult Comments(int IDcontent, int IDpage, string Username)
        {
            ContentComments model = new ContentComments();

            using (ZavrsniEFentities db = new ZavrsniEFentities())
            {
                var selectedContent = (from c in db.Content
                                       where c.IDcontent == IDcontent
                                       select c).Include(c => c.User).ToList();
                var user = db.User.Find(selectedContent.FirstOrDefault().IDauthor);
                model.ContentText  = selectedContent.FirstOrDefault().Text;
                model.ContentOwner = user.Username;
                model.Title        = selectedContent.FirstOrDefault().Title;
                model.IDcontent    = IDcontent;
                model.IDpage       = IDpage;
                model.Username     = Username;
                var allComments = (from c in db.ContentComment
                                   where c.IDcontent == IDcontent
                                   orderby c.Timestamp descending
                                   select c).Include(c => c.User).ToList();
                model.AllComments = allComments;
            }
            return(View(model));
        }
Esempio n. 5
0
        public ActionResult DeleteArticle(int? id)
        {
            mu = Membership.GetUser();

            var model = new BootBaronLib.AppSpec.DasKlub.BOL.UserContent.Content();

            if (id != null && id > 0)
            {
                model = new BootBaronLib.AppSpec.DasKlub.BOL.UserContent.Content(
                    Convert.ToInt32(id));

                ContentComments concoms = new ContentComments();
                concoms.GetCommentsForContent(model.ContentID, SiteEnums.CommentStatus.U);
                concoms.GetCommentsForContent(model.ContentID, SiteEnums.CommentStatus.C);

                if (model.CreatedByUserID == Convert.ToInt32(mu.ProviderUserKey))
                {
                    // security check
                    foreach (ContentComment c1 in concoms)
                        c1.Delete();

                    model.Delete();
                }

            }

            return RedirectToAction("Articles");
        }
Esempio n. 6
0
        public ActionResult DeleteArticle(int? id)
        {
            if (id == null || !(id > 0)) return RedirectToAction("Articles");

            var model = new Content(
                Convert.ToInt32(id));

            var concoms = new ContentComments();
            concoms.GetCommentsForContent(model.ContentID, SiteEnums.CommentStatus.U);
            concoms.GetCommentsForContent(model.ContentID, SiteEnums.CommentStatus.C);

            foreach (ContentComment c1 in concoms)
                c1.Delete();

            model.Delete();

            return RedirectToAction("Articles");
        }
Esempio n. 7
0
        public ActionResult DeleteArticle(int? id)
        {
            if (id == null || !(id > 0)) return RedirectToAction("Articles");

            var model = new Content(Convert.ToInt32(id));

            var concoms = new ContentComments();
            concoms.GetCommentsForContent(model.ContentID, SiteEnums.CommentStatus.U);
            concoms.GetCommentsForContent(model.ContentID, SiteEnums.CommentStatus.C);

            if (_mu == null || model.CreatedByUserID != Convert.ToInt32(_mu.ProviderUserKey))
                return RedirectToAction("Articles");

            // security check
            foreach (var c1 in concoms) c1.Delete();

            model.Delete();

            return RedirectToAction("Articles");
        }
Esempio n. 8
0
        public ActionResult DeleteArticle(int? id)
        {
            var model = new BootBaronLib.AppSpec.DasKlub.BOL.UserContent.Content();

            if (id != null && id > 0)
            {
                model = new BootBaronLib.AppSpec.DasKlub.BOL.UserContent.Content(
                    Convert.ToInt32(id));

                ContentComments concoms = new ContentComments();
                concoms.GetCommentsForContent(model.ContentID, SiteEnums.CommentStatus.U);
                concoms.GetCommentsForContent(model.ContentID, SiteEnums.CommentStatus.C);

                foreach (ContentComment c1 in concoms)
                    c1.Delete();

                model.Delete();

            }

            return RedirectToAction("Articles");
        }