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); }
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()); }
public CommentDetailPage(Comment comment) { InitializeComponent(); BindingContext = new CommentDetailViewModel(comment); }