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; } }
public PostController(IPostQueryService postQueryService, IPostCommandService postCommandService, IUserService userService) { _postQueryService = postQueryService; _postCommandService = postCommandService; _userService = userService; }