コード例 #1
0
 public CommentsServiceTests()
 {
     this.service = new CommentsService();
     service.Add(new Comments { Text = "Nice" }
         );
     service.Add(new Comments { Text = "Delicious" }
         );
 }
コード例 #2
0
 public CommentsServiceTests()
 {
     this.service = new CommentsService();
     service.Add(new Comments {
         Text = "Nice"
     }
                 );
     service.Add(new Comments {
         Text = "Delicious"
     }
                 );
 }
コード例 #3
0
        public IActionResult PostComment(string CommentContent, string PagePath, string ReplyTo, string Title)
        {
            string referer = Request.GetReferer();

            if (referer.IsNullOrEmpty())
            {
                return(new HttpBadRequestResult());
            }
            if (_applicationContextAccessor.Current.CurrentCustomer != null &&
                CommentContent.IsNotNullAndWhiteSpace() &&
                CommentContent.Length <= 500 &&
                PagePath.IsNotNullAndWhiteSpace())
            {
                _commentService.Add(new Comments
                {
                    UserId         = _applicationContextAccessor.Current.CurrentCustomer.UserID,
                    Picture        = _applicationContextAccessor.Current.CurrentCustomer.PhotoUrl,
                    UserName       = _applicationContextAccessor.Current.CurrentCustomer.UserName,
                    PagePath       = PagePath,
                    Title          = Title,
                    CommentContent = CommentContent,
                    Status         = (int)RecordStatus.Active
                });
                return(Redirect(referer));
            }
            else
            {
                return(RedirectToAction("SignIn", "Account", new { ReturnUrl = new Uri(referer).AbsolutePath }));
            }
        }
コード例 #4
0
        public IActionResult Comment(int id, AddCommentModel newComment)
        {
            int userId = int.Parse(HttpContext.User.FindFirstValue("Id"));

            _commentsService.Add(userId, ICommentsService.CommentType.Question, id, newComment.Message);
            return(RedirectToAction("Details", new { id }));
        }
コード例 #5
0
 public ActionResult AddComment(Comment comment, string subjectTitle)
 {
     if (!ModelState.IsValid)
     {
         return(View(comment));
     }
     comment.PostedOn = DateTime.Now;
     _commentsService.Add(comment);
     return(Redirect(String.Format("/Subjects/Subject?title={}", subjectTitle)));
 }
コード例 #6
0
        public HttpResponseMessage Add(CommentAddRequest request)
        {
            if (!ModelState.IsValid || request == null)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState));
            }
            int commentId = _commentsService.Add(request, _currentUser.Id);
            ItemResponse <int> response = new ItemResponse <int>();

            response.Item = commentId;
            return(Request.CreateResponse(HttpStatusCode.OK, response));
        }
コード例 #7
0
        public void AddTest()
        {
            var text       = Guid.NewGuid().ToString();
            var NewComment = new Comments
            {
                Text = text
            };
            var AddedComment = service.Add(NewComment);

            Assert.IsNotNull(AddedComment);
            Assert.IsTrue(AddedComment.Id > 0);
            Assert.AreEqual(AddedComment.Text, text);
        }
コード例 #8
0
        public IActionResult Add([FromBody] CommentCreateRequestModel commentCreateModel)
        {
            var userId = int.Parse(User.FindFirst("Id").Value);

            var response = _commentsService.Add(commentCreateModel.Comment, commentCreateModel.RecipeId, userId);

            if (response.Status.IsSuccessful)
            {
                return(Ok(response.Comment.ToCommentModel()));
            }
            else
            {
                return(BadRequest(new { Message = response.Status.Message }));
            }
        }
コード例 #9
0
        public IActionResult Add(CommentCreateModel commentCreateModel)
        {
            var userId = int.Parse(User.FindFirst("Id").Value);

            var response = _commentsService.Add(commentCreateModel.Comment, commentCreateModel.TicketId, userId);

            if (response.IsSuccessful)
            {
                return(RedirectToAction("Details", "Ticket", new { id = commentCreateModel.TicketId }));
            }
            else
            {
                return(RedirectToAction("ActionNonSuccessful", "Info", new { Message = response.Message }));
            }
        }
コード例 #10
0
        public IResult AddComments([FromBody] Comments model)
        {
            AutUserInfo userInfo      = _httpContext.HttpContext.Session.GetObject <AutUserInfo>("UserInfo");
            string      resultmessage = StaticValues.ErrorMessage;
            int         resultcode    = StaticValues.ErrorCode;
            bool        resultval     = false;

            try
            {
                _logs.Add(userInfo.SessId, string.Format("Makale ekleme işlemi ekli parametreler ile başlamıştır.{0}", Reflections.GetModelPropertyValues <Comments>(model)), "AddComments", "CommentsController", Enum.GetName(typeof(LayerInfo), 1), "", userInfo.ClientIp, userInfo.UsrId);
                var result = _comment.Add(model, userInfo);
                resultcode    = result.ResultCode;
                resultmessage = result.Message;
                resultval     = result.IsSuccess;
                _logs.Add(userInfo.SessId, string.Format("Makale ekleme işlemi tamamlanmıştır.Sonuç={0}", (resultval ? "Başarılı" : "Hatalı")), "AddComments", "CommentsController", Enum.GetName(typeof(LayerInfo), 1), "", userInfo.ClientIp, userInfo.UsrId);
            }
            catch (Exception ex)
            {
                _logs.Add(userInfo.SessId, ex.ToString(), "AddComments", "CommentsController", Enum.GetName(typeof(LayerInfo), 1), "", userInfo.ClientIp, userInfo.UsrId);
            }
            return(new Result(resultval, resultmessage, resultcode));
        }
コード例 #11
0
ファイル: CommentsController.cs プロジェクト: enaki/Couponel
        public async Task <IActionResult> Add([FromRoute] Guid couponId, [FromBody] CreateCommentModel model)
        {
            var result = await _commentsService.Add(couponId, model);

            return(Created(result.Id.ToString(), null));
        }