Ejemplo n.º 1
0
 public ActionResult Create(CommentCreateVM comment)
 {
     if (ModelState.IsValid)
     {
         try
         {
             _commentLogic.AddComment(Mapper.Map <CommentCreateVM, Comment>(comment));
             return(RedirectToAction("Index", new { idShop = comment.IDShop }));
         }
         catch (Exception ex)
         {
             ModelState.AddModelError(String.Empty, ex);
         }
     }
     return(View(comment));
 }
        public ActionResult <Comment> PostComment([FromBody] Comment comment)
        {
            string authHeaderValue = Request.Headers["Authorization"];
            var    tokenClaims     = GetClaims(authHeaderValue.Substring("Bearer ".Length).Trim());

            comment.UserId = Convert.ToInt32(tokenClaims.Claims.Where(c => c.Type == ClaimTypes.NameIdentifier).FirstOrDefault().Value);
            if (comment.Message != null)
            {
                comment.Posted = DateTime.Now;
                _commentLogic.AddComment(comment);
                return(Ok());
            }
            else
            {
                return(StatusCode(422));
            }
        }
        public IActionResult AddComment([FromBody] CommentDto commentDto)
        {
            var comment = _commentLogic.AddComment(commentDto);

            return(Ok());
        }
Ejemplo n.º 4
0
 public void AddComment(string UserName, string Text, int animalId)
 {
     _commentLogic.AddComment(UserName, Text, animalId);
 }