Ejemplo n.º 1
0
        /// <summary>
        /// Changes the status of a post to active.
        /// </summary>
        /// <param name="postId">the id of the post to set to active status</param>
        /// <returns>fase if it is trying to change the status on a post that is not allowed, true if everything works ok</returns>
        public JsonResult RepostItem(int postId, DateTime expirationDate)
        {
            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 == 1 || newPost.PostStatus == 3 || newPost.PostStatus == 5)
            {
                return(Json("false", JsonRequestBehavior.AllowGet));
            }

            UpdatePostToActiveCommand command = new UpdatePostToActiveCommand(postId, expirationDate, user.LoginName);

            commandBus.Execute(command);

            return(Json("true", JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Updates a post to active and updates the expiration date.
 /// </summary>
 /// <param name="command">the UpdatePostToActive command</param>
 public void HandleCommand(UpdatePostToActiveCommand command)
 {
     postRepository.UpdatePostToActiveAndUpdateExpirationDate(command.PostId, command.ExpirationDate, command.UserName);
 }