/// <summary> /// Marks a post as deliverd by changing its status /// </summary> /// <param name="postId">the id of the post to change the status of</param> /// <returns>true / false, true if the status is successfully changed, false if not.</returns> public JsonResult MarkPostAsDelivered(int postId) { ClaimsIdentity id = (ClaimsIdentity)User.Identity; //Queries for the current user and their email address. - Chris SelectUserQuery currentUser = new SelectUserQuery(new CurrentUser(id.Claims.ElementAt(0).Value)); CurrentUser user = commandBus.ProcessQuery(currentUser); GetPostByPostIdQuery query = new GetPostByPostIdQuery(postId); Post newPost = commandBus.ProcessQuery(query); if (newPost.PostStatus != 2) { return(Json("false", JsonRequestBehavior.AllowGet)); } UpdatePostToDeliveredCommand command = new UpdatePostToDeliveredCommand(new Post(postId), user.LoginName); commandBus.Execute(command); return(Json("true", JsonRequestBehavior.AllowGet)); }
/// <summary> /// Handler for the UpdatePostToDeliveredCommand command /// </summary> /// <param name="command">the UpdatePostToDelivered Command</param> public void HandleCommand(UpdatePostToDeliveredCommand command) { postRepository.UpdatePostToDelivered(command.Post, command.UserName); }