コード例 #1
0
ファイル: AjaxController.cs プロジェクト: rodown/funwithoiky
        public JsonResult FetchCommentListForPerson(JqGridRequest request, int personId)
        {
            var jqGridData = new JqGridData();
            if (Session[SessionVariable.LoggedOnPerson] != null)
            {
                var currentPerson = (Person)Session[SessionVariable.LoggedOnPerson];
                ICommentService commentService = new CommentService(new CommentRepository(_context));
                IGridFormatter gridFormatter = new GridFormatter();
                var comments = commentService.GetListOfComments(currentPerson, personId);
                jqGridData = gridFormatter.FormatCommentsForGrid(comments, request);
            }

            return Json(jqGridData);
        }
コード例 #2
0
ファイル: AjaxController.cs プロジェクト: rodown/funwithoiky
        public JsonResult SaveComments(int personId, IEnumerable<string> comments)
        {
            var sessionTimedOut = false;
            if (Session[SessionVariable.LoggedOnPerson] == null)
            {
                sessionTimedOut = true;
            }
            else
            {
                ICommentService commentService = new CommentService(new CommentRepository(_context));
                var newComments = comments.Select(comment => new CommentDto {AboutPersonId = personId, Comment = comment, CommentDate = DateTime.Now}).ToList();
                commentService.SaveComments((Person)Session[SessionVariable.LoggedOnPerson], newComments);
            }

            var response = new { SessionTimeOut = sessionTimedOut };
            return Json(response, JsonRequestBehavior.DenyGet);
        }
コード例 #3
0
ファイル: AjaxController.cs プロジェクト: rodown/funwithoiky
        public JsonResult SavePersonComment(int personId, string comment)
        {
            var sessionTimedOut = false;
            var message = string.Empty;
            if (Session[SessionVariable.LoggedOnPerson] == null)
            {
                sessionTimedOut = true;
                message = ExceptionMessage.SessionTimedOut;
            }
            else
            {
                var currentPerson = (Person)Session[SessionVariable.LoggedOnPerson];
                if (currentPerson.HasPermission(Permissions.AddComment))
                {
                    ICommentService commentService = new CommentService(new CommentRepository(_context));
                    try
                    {
                        commentService.SaveComment(currentPerson,
                                                   new CommentDto
                                                       {
                                                           AboutPersonId = personId,
                                                           Comment       = comment,
                                                           CommentDate   = DateTime.Now
                                                       });
                        message = "Comment Saved";
                    }
                    catch (Exception ex)
                    {
                        Email.SendExceptionEmail(ex);
                        message = "There was a problem saving your comment.  Our developers have been notified and will let you know when the problem has been fixed";
                    }
                }
                else
                {
                    message = ExceptionMessage.InvalidCredentials;
                }
            }

            var response = new
            {
                SessionTimeOut = sessionTimedOut,
                Message = message
            };
            return Json(response, JsonRequestBehavior.DenyGet);
        }
コード例 #4
0
ファイル: AjaxController.cs プロジェクト: rodown/funwithoiky
        public JsonResult FetchPersonCommentHistory(int personId)
        {
            var sessionTimedOut = false;
            var message = string.Empty;
            var comments = new List<CommentDto>();
            if (Session[SessionVariable.LoggedOnPerson] == null)
            {
                sessionTimedOut = true;
                message = ExceptionMessage.SessionTimedOut;
            }
            else
            {
                var currentPerson = (Person)Session[SessionVariable.LoggedOnPerson];
                if (currentPerson.HasPermission(Permissions.ViewComments))
                {
                    ICommentService commentService = new CommentService(new CommentRepository(_context));
                    comments = commentService.GetListOfComments(currentPerson, personId, 5).ToList();
                }
                else
                {
                    message = ExceptionMessage.InvalidCredentials;
                }
            }

            var response = new
            {
                SessionTimeOut = sessionTimedOut,
                Message = message,
                Comments = comments
            };
            return Json(response, JsonRequestBehavior.DenyGet);
        }