Ejemplo n.º 1
0
        public static Comment ToEntityModel(this CommentDetailViewModel commentDetailViewModel, Comment comment, int userId)
        {
            var entity = Mapper.Map(commentDetailViewModel, comment);

            entity.CreatedDate = DateTime.Now;
            entity.UserId      = userId;

            return(comment);
        }
Ejemplo n.º 2
0
        public IActionResult CreateComment(CommentDetailViewModel model)
        {
            var currentUserId = HttpContext.Session.GetInt32("_Id").Value;

            if (ModelState.IsValid)
            {
                var comment = new Comment();
                model.ToEntityModel(comment, currentUserId);
                _commentService.Create(comment);

                return(Ok(comment));
            }

            return(BadRequest());
        }
Ejemplo n.º 3
0
 public CommentDetailPage(Comment comment)
 {
     InitializeComponent();
     BindingContext = new CommentDetailViewModel(comment);
 }