예제 #1
0
        public ActionResult PublishPostByCommand(int topicId, string content)
        {
            try
            {
                IPostCommandService postCommandService = ServiceLocator.Instance.GetService <IPostCommandService>();

                PostDataObject postDataObject = new PostDataObject();
                postDataObject.Author.Id   = GlobalApplication.LoginUser.Id;
                postDataObject.Author.Name = GlobalApplication.LoginUser.Name;
                postDataObject.Topic.Id    = topicId;
                postDataObject.Content     = content;
                //postDataObject.CreationDateTime = DateTime.Now;

                postCommandService.PublishPost(postDataObject);

                return(View("index", postDataObject));

                //return Json(new
                //{
                //    topic = postDataObject.TopicName,
                //    author = postDataObject.AuthorName,
                //    content = postDataObject.Content,
                //    date = postDataObject.CreationDateTime
                //});
            }
            catch (Exception e)
            {
                throw e;
            }
        }
예제 #2
0
 public PostController(IPostQueryService postQueryService, IPostCommandService postCommandService, IUserService userService)
 {
     _postQueryService   = postQueryService;
     _postCommandService = postCommandService;
     _userService        = userService;
 }