async void PostCommentClick(object sender, EventArgs args)
        {
            if (Constantes.authModel != null && Constantes.authModel.Connected)
            {
                bool succeed = await CommentsModel.PostComment(comment.Text, placeID);

                if (succeed)
                {
                    DependencyService.Get <IMessage>().ShortAlert("Thanks for your comment !");

                    Place p = CommentsModel.GetPlaceWithComments(placeID);
                    BindingContext = new PlaceDetailsViewModel {
                        BindedPlace = p
                    };
                    ListComments.ItemsSource = p.comments;
                }
                else
                {
                    DependencyService.Get <IMessage>().ShortAlert("An error occured while posting your comment. Please try again later.");
                }
            }
            else
            {
                DependencyService.Get <IMessage>().ShortAlert("You must be logged to comment.");
            }
            comment.Text = "";
        }
Пример #2
0
        public ActionResult Create(CommentsModel commentsModel, CommentsNews commentsNews)
        {

            if (ModelState.IsValid)
            {
                var user = User.Identity;


                CommentsModel comment = new CommentsModel();
                comment.Text = commentsModel.Text;
                comment.IdUser = user.GetUserId();
                comment.UserName = user.Name;
                comment.NewsId = commentsNews.NewsId;


                db.Comments.Add(comment);
                db.SaveChanges();

                var lastComment = db.Comments.Max(p => p.Id);

                CommentsNews commentNews = new CommentsNews();
                commentNews.CommentId = lastComment;
                commentNews.NewsId = commentsNews.NewsId;

                db.CommentsNews.Add(commentNews);
                db.SaveChanges();

                return RedirectToAction("Details", "News", new { id = commentsModel.NewsId });
            }

            return View(commentsModel);
        }
Пример #3
0
        private CommentsModel GetModel(Int32 parentId, CommonUnit.CommentType type)
        {
            CommentsModel model = new CommentsModel();

            model.Comments = new List <Models.Comment>();

            try {
                List <CommentUnion> comments = _commentService.GetComments(SessionData.customer.id, parentId, type);

                foreach (CommentUnion comment in comments)
                {
                    Models.Comment comm = new Models.Comment();
                    comm.id          = comment.id;
                    comm.ParentId    = comment.ParentId;
                    comm.CommentText = comment.CommentText;
                    comm.Selected    = comment.Selected;
                    model.Comments.Add(comm);
                }
            }
            catch (Exception ex) {
                base.Log(ex);
            }
            finally {
            }

            return(model);
        }
Пример #4
0
        /// 转换List<T> 评论表
        /// </summary>
        /// <param name="info"></param>
        /// <returns></returns>
        public List <CommentsModel> TurnListModel(List <Comments> info)
        {
            List <CommentsModel> List = new List <CommentsModel>();

            if (info.Count > 0)
            {
                foreach (var dt in info)
                {
                    CommentsModel model = new CommentsModel();
                    model.Id           = dt.Id;
                    model.Content      = dt.Content;
                    model.CreateDate   = dt.CreateDate;
                    model.UpdateDate   = dt.UpdateDate;
                    model.IsDelete     = dt.IsDelete;
                    model.Name         = dt.Name;
                    model.ChildId      = dt.ChildId;
                    model.ImgUrl       = dt.ImgUrl;
                    model.PraiseNum    = dt.PraiseNum;
                    model.PublicDate   = dt.PublicDate;
                    model.UserId       = dt.UserId;
                    model.ToCommentsId = dt.ToCommentsId;
                    List.Add(model);
                }
            }
            return(List);
        }
Пример #5
0
        public ActionResult GetCommentsForSite(string number)
        {
            var model = new CommentsModel();

            model.FindComments(int.Parse(number));
            return(View("CommentsPanel", model));
        }
Пример #6
0
        // GET api/comment/5
        public CommentsModel Get(int id)
        {
            var foundComments = new CommentsModel();

            foundComments.FindComments(id);
            return(foundComments);
        }
Пример #7
0
        public IHttpActionResult Add(int postId, CommentsModel commentUpload)
        {
            if (commentUpload == null)
            {
                this.ModelState.AddModelError("comment", "There is no comment");
            }

            if (this.data.Users.All().Count(u => u.Id == commentUpload.UserId) == 0)
            {
                this.ModelState.AddModelError("user", "Invalid User");
            }

            if (!this.ModelState.IsValid)
            {
                return(this.BadRequest(this.ModelState));
            }

            var comment = Mapper.Map <Comment>(commentUpload);

            comment.PostId = postId;
            comment.UserId = this.User.Identity.GetUserId();
            this.data.Comments.Add(comment);
            this.data.SaveChanges();

            return(this.Ok(comment));
        }
        public void UpdateComment(int id, CommentsModel comment)
        {
            var updateComments = GetCommentByID(id);

            updateComments.Id      = comment.Id;
            updateComments.Comment = comment.Comment;
        }
Пример #9
0
        public IActionResult EditComments(CommentsModel comments)
        {
            var sem = _db.Semesters.Include(x => x.Comments).Where(x => x.Id == comments.SemesterId).FirstOrDefault();

            for (int i = 0; i < comments.DekanDescriptions?.Count(); i++)
            {
                sem.Comments[i].DekanDescription = comments.DekanDescriptions[i];
            }
            for (int i = 0; i < comments.TeacherDescriptions?.Count(); i++)
            {
                sem.Comments[i].TeacherDescription = comments.TeacherDescriptions[i];
            }
            _db.SaveChanges();

            if (User.IsInRole("admin"))
            {
                return(RedirectToAction("Index", "Settings"));
            }
            if (User.IsInRole("dekan"))
            {
                return(RedirectToAction("Index", "Dekan"));
            }
            if (User.IsInRole("teacher"))
            {
                return(RedirectToAction("Index", "Settings"));
            }


            return(RedirectToAction("Index"));
        }
Пример #10
0
        public async Task RenderComments()
        {
            var comments = new List <Comment>();

            foreach (var x in ViewModel.Comments)
            {
                var body = await _markdownService.Convert(x.Body);

                comments.Add(new Comment(x.User.AvatarUrl, x.User.Login, body, x.CreatedAt));
            }

            var events = ViewModel
                         .Events
                         .Select(x => new Comment(x.Actor.AvatarUrl, x.Actor.Login, CreateEventBody(x.Event.StringValue, x.CommitId), x.CreatedAt));

            var items = comments
                        .Concat(events)
                        .Where(x => !string.IsNullOrEmpty(x.Body))
                        .OrderBy(x => x.Date)
                        .ToList();

            var commentModel = new CommentsModel(items, (int)UIFont.PreferredSubheadline.PointSize);
            var razorView    = new CommentsWebView {
                Model = commentModel
            };
            var html = razorView.GenerateString();

            InvokeOnMainThread(() => {
                _commentsElement.SetValue(!comments.Any() ? null : html);
                Render();
            });
        }
Пример #11
0
        public async Task <ActionResult> PutComment(CommentsModel comment)
        {
            IEnumerable <Comment>           comments;
            IEnumerable <CommentsViewModel> newModel;

            try{
                var model = await _commemtContext.GetComment(comment.CommentId);

                model.Body = comment.Body;
                var result = await _commemtContext.Update(model);

                if (!result.Succeeded)
                {
                    return(StatusCode(StatusCodes.Status500InternalServerError, result.Error));
                }

                comments = await _commemtContext.GetAllPostComment(comment.PostId);

                if (comments.Count() > 0)
                {
                    newModel = _mapper.Map <IEnumerable <Comment>, IEnumerable <CommentsViewModel> >(comments);
                    await _hub.Clients.All.SendAsync("comment", newModel);
                }
            }
            catch (Exception e) {
                _logger.LogError(e.InnerException?.ToString() ?? e.Message);
                _mailService.SendMail(string.Empty, e.InnerException?.ToString() ?? e.Message, "error");
                return(StatusCode(statusCode: StatusCodes.Status500InternalServerError, "Internal server error"));
            }

            return(Ok(new { Success = true }));
        }
Пример #12
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Body,UserID,PostDate,QuestionID,AnswerID")] CommentsModel commentsModel)
        {
            if (id != commentsModel.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(commentsModel);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CommentsModelExists(commentsModel.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(commentsModel));
        }
Пример #13
0
 // POST: api/Comments
 public void Post(CommentsModel sentComment)
 {
     //CommentsList commentsList = new CommentsList();
     //commentsList.PostComments = new CommentsModel().InsertComment(sentComment);
     //return commentsList;
     new CommentsModel().InsertComment(sentComment);
 }
        public IHttpActionResult Add(int postId, CommentsModel commentUpload)
        {
            if (commentUpload == null)
            {
                this.ModelState.AddModelError("comment", "There is no comment");
            }

            if (this.data.Users.All().Count(u => u.Id == commentUpload.UserId) == 0)
            {
                this.ModelState.AddModelError("user", "Invalid User");
            }

            if (!this.ModelState.IsValid)
            {
                return this.BadRequest(this.ModelState);
            }

            var comment = Mapper.Map<Comment>(commentUpload);
            comment.PostId = postId;
            comment.UserId = this.User.Identity.GetUserId();
            this.data.Comments.Add(comment);
            this.data.SaveChanges();

            return this.Ok(comment);
        }
        public PlaceDetails(int id = 1)
        {
            InitializeComponent();

            placeID = id;
            Place p = CommentsModel.GetPlaceWithComments(id);

            BindingContext = new PlaceDetailsViewModel {
                BindedPlace = p
            };
            Title = ((PlaceDetailsViewModel)BindingContext)?.BindedPlace.title;

            ListComments.ItemsSource = p.comments;

            // Setting map properties to make it show the current place
            Position pos = new Position(p.latitude, p.longitude);

            map.InitialCameraUpdate = CameraUpdateFactory.NewCameraPosition(
                new CameraPosition(
                    pos,
                    13,
                    0,
                    0
                    )
                );

            Pin pin = new Pin();

            pin.Position = pos;
            pin.Label    = p.title;
            map.Pins.Add(pin);

            Constantes.authModel?.AutoRefreshToken();
        }
Пример #16
0
        public CommentsModel Post(CommentsModel newComment)
        {
            try
            {
                using (WebSiteContext db = new WebSiteContext())
                {
                    var comment = new Comment();
                    comment.CreateDate   = DateTime.Now;
                    comment.ArticleId    = newComment.ArticleId;
                    comment.CommentText  = newComment.CommentText;
                    comment.CommentTitle = newComment.CommentTitle;
                    comment.UserId       = newComment.UserId;
                    comment.UserName     = newComment.UserName;
                    db.Comments.Add(comment);
                    db.SaveChanges();

                    newComment.CommentId  = comment.CommentId;
                    newComment.CreateDate = comment.CreateDate.ToShortDateString();
                    newComment.success    = "ok";

                    newComment.success = new GodaddyEmailController().SendEmail("Somebody Actually Made A comment", comment.UserName + " said: " + comment.CommentText);
                }
            }
            catch (Exception ex)
            {
                newComment.success = Helpers.ErrorDetails(ex);
            }
            return(newComment);
        }
        public void ValidOK()
        {
            //create an instance of the class we want to create
            CommentsModel Comment = new CommentsModel();

            //test to see that it exists
            Assert.IsNotNull(Comment);
        }
        public ActionResult DeleteConfirmed(int id)
        {
            CommentsModel commentsModel = db.CommentsModels.Find(id);

            db.CommentsModels.Remove(commentsModel);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Пример #19
0
 public ActionResult SaveEditComment(CommentsModel model)
 {
     if (Session["userID"] != null)
     {
         UpdateComment(model.ID, model.Content);
     }
     return(RedirectToAction("MovieDetails", "Movie", new { id = model.MovieID }));
 }
Пример #20
0
 public Task <CommentsModel> createComments(CommentsModel param_obj)
 {
     param_obj.COMMENTS_ID    = Guid.NewGuid();
     param_obj.DATE_SUBMITTED = DateTime.Now;
     param_obj.STATUS         = true;
     knowledgeBaseCommentDb.Insert(param_obj);
     return(Task.FromResult(param_obj));
 }
Пример #21
0
        public ActionResult DeleteComment(string commentId, string siteId)
        {
            var model = new CommentsModel();

            model.DeleteComment(int.Parse(commentId));
            model.FindComments(int.Parse(siteId));
            return(View("CommentsPanel", model));
        }
Пример #22
0
        public ActionResult Comment(int id)
        {
            var comment = new CommentsModel()
            {
                CampaignId = id
            };

            return(View(comment));
        }
Пример #23
0
        public ActionResult Index(string commentText)
        {
            Comment newComment = new Comment();

            newComment.email   = Session["email"].ToString();
            newComment.comment = commentText;
            CommentsModel.InsertComment(newComment);
            return(RedirectToAction("Index", "Comments"));
        }
Пример #24
0
        protected override async Task OnParametersSetAsync()
        {
            var node = await NodeService.GetAsync(Id);

            Post         = Models.Post.Create(node);
            PostUserName = !string.IsNullOrEmpty(node.CreatedBy) ? await UserService.GetUserNameAsync(node.CreatedBy) : string.Empty;

            Comments = new CommentsModel(NodeService)
            {
                NodeSearch = new NodeSearch()
                {
                    Module   = Constants.ForumsModule,
                    Type     = Constants.CommentType,
                    ParentId = Post.Id,
                    OrderBy  = new string[]
                    {
                        OrderBy.Hot,
                        OrderBy.Latest
                    }
                }
            };
            await Comments.InitAsync();

            var loggedInUserId = (await AuthenticationStateTask).LoggedInUserId();

            CanEditPost = await SecurityService.AllowedAsync(
                loggedInUserId,
                Post.CreatedBy,
                Constants.ForumsModule,
                Constants.PostType,
                Actions.Edit
                );

            CanDeletePost = await SecurityService.AllowedAsync(
                loggedInUserId,
                Post.CreatedBy,
                Constants.ForumsModule,
                Constants.PostType,
                Actions.Delete
                );

            CanAddComment = await SecurityService.AllowedAsync(
                loggedInUserId,
                null,
                Constants.ForumsModule,
                Constants.CommentType,
                Actions.Add
                );

            CanVote = await SecurityService.AllowedAsync(
                loggedInUserId,
                null,
                Constants.ForumsModule,
                Constants.PostType,
                Actions.Vote
                );
        }
Пример #25
0
        internal static string GetUrlForWriteComment(CommentsModel model)
        {
            var url = new Dictionary <string, string>
            {
                { "Id", model.AuctionId }
            };

            return(MakeQueryString(url));
        }
        public async Task <CommentsModel> createComments(CommentsModel param_obj)
        {
            var result = await mediator.Send(new CommentsCommand()
            {
                param_obj = param_obj
            });

            return(result);
        }
Пример #27
0
 public CommentNewsModel(CommentsModel model, UserModel user)
 {
     //Title
     Title        = model.Title;
     Author       = user;
     PostID       = model.NewsLookup;
     DateCreated  = model._DCDateCreated;
     DateModified = model._DateModified;
     CommentBody  = model.CommentBody;
 }
        public void Rate_MaxMinus1()
        {
            CommentsModel comments = new CommentsModel();
            //test data to assign to the test
            Int32    Rating = 9;
            DateTime date   = new DateTime(2021, 1, 01);
            string   valid  = comments.valid(Rating, date);

            Assert.AreEqual(valid, "");
        }
        public void Rate_ExtremeMax()
        {
            CommentsModel comments = new CommentsModel();
            //test data to assign to the test
            Int32    Rating = 20;
            DateTime date   = new DateTime(2021, 1, 01);
            string   valid  = comments.valid(Rating, date);

            Assert.AreEqual(valid, "To high rating");
        }
Пример #30
0
        private void CreateBlogMessage(CommentsModel model)
        {
            var contentService = ApplicationContext.Current.Services.ContentService;
            var pageName       = CurrentPage.Name;
            var allEventsNode  = GetAllEventsNode();
            var content        = contentService.CreateContent(pageName, allEventsNode.Id, "reviewComments");

            content.SetValue("messageTitle", model.MessageTitle);
            content.SetValue("visitorMessage", model.VisitorMessage);
            contentService.SaveAndPublishWithStatus(content);
        }
Пример #31
0
        public static List <UpdatesModel> GetListOfUpdates(string username)
        {
            int id = 0;

            //fetch the userid. Handle the exception when the username is empty
            try
            {
                id = FetchUserId(username);
            }
            catch
            {
            }
            List <UpdatesModel> lstupdates = new List <UpdatesModel>();

            using (var db = new UsersContext())
            {
                var updates = db.Updates.OrderByDescending(f => f.datecreated).ToList();
                if (String.IsNullOrEmpty(username))
                {
                    db.Updates.OrderByDescending(f => f.datecreated).ToList();
                }
                db.Updates.OrderByDescending(f => f.datecreated).ToList();
                foreach (Updates up in updates)
                {
                    var upmodel = new UpdatesModel();
                    upmodel.data         = up.data;
                    upmodel.datecreated  = up.datecreated;
                    upmodel.datemodified = up.datemodified;
                    upmodel.status       = up.status;
                    upmodel.updateid     = up.updateid;
                    upmodel.userid       = up.userid;
                    var updateuser = GetUserDetailsId(up.userid);
                    upmodel.updatename = updateuser.firstname + " " + updateuser.lastname;
                    upmodel.comments   = new List <CommentsModel>();
                    var comments = db.Comments.Where(f => up.updateid == f.updateid).OrderByDescending(f => f.datecreated).ToList();
                    foreach (Comments cm in comments)
                    {
                        var cmmodel = new CommentsModel();
                        cmmodel.data      = cm.data;
                        cmmodel.commentid = cm.commentid;
                        var commentuser = GetUserDetailsId(cm.userid);
                        cmmodel.commentsname = commentuser.firstname + " " + commentuser.lastname;
                        cmmodel.datecreated  = cm.datecreated;
                        cmmodel.datemodified = cm.datemodified;
                        cmmodel.status       = cm.status;
                        cmmodel.updateid     = cm.updateid;
                        cmmodel.userid       = cm.userid;
                        upmodel.comments.Add(cmmodel);
                    }
                    lstupdates.Add(upmodel);
                }
                return(lstupdates);
            }
        }
        public async Task <long> AddAsync(CommentsModel obj)
        {
            Comments comment = new Comments()
            {
                userId         = obj.userId,
                blogId         = obj.blogId,
                commentContent = obj.commentContent
            };

            return(await _repository.AddAsync(comment));
        }
Пример #33
0
        public void InsertComment(CommentsModel sentComment)
        {
            SqlParameter[] parameters = new SqlParameter[]
            {
                new SqlParameter("@POSTID", sentComment.PostId),
                new SqlParameter("@USERID", sentComment.UserId),
                new SqlParameter("@COMMENT", sentComment.Comment),
                new SqlParameter("@LOCATION", sentComment.Location),
            };

            ExecuteSPNonReturnData("InsertComment", parameters);
        }