コード例 #1
0
        public async Task <IActionResult> Delete(OtherPostActivitiesPostVM postToDelete)
        {
            var post = await _postService.GetPost(postToDelete.PostId);

            var delete = await _postService.DeletePost(post);

            return(RedirectToAction("Index", "Admin"));
        }
コード例 #2
0
        public async Task <IActionResult> Edit(OtherPostActivitiesPostVM postToUpdate)
        {
            var post = await _postService.GetPost(postToUpdate.PostId);

            var assignEditedData = PostMappers.MapToEditedPostView(post, postToUpdate);
            var edit             = await _postService.EditPost(post);

            return(RedirectToAction("Editor", "Editor"));
        }
コード例 #3
0
ファイル: PostMappers.cs プロジェクト: lexTutor/BLOGITWebApp
        /// <summary>
        /// Maps a post entity to an OtherPostActivitiesPost view model.
        /// </summary>
        /// <param name="post"></param>
        /// <returns></returns>
        public static OtherPostActivitiesPostVM ConvertToOtherPostVM(Post post)
        {
            OtherPostActivitiesPostVM viewModelPost = new OtherPostActivitiesPostVM
            {
                PostId          = post.PostId,
                CommentCount    = post.Comments.Count,
                PostCategories  = string.Join(", ", ReturnCategories(post.PostCategories)),
                ImagePath       = post.ImagePath,
                Likes           = post.Likes.Count,
                PostCreatorName = post.PostCreator.FirstName + " " + post.PostCreator.LastName,
                PostDetails     = post.PostDetails,
                PostTitle       = post.PostTitle,
                ApprovalState   = post.ApprovalState
            };

            return(viewModelPost);
        }
コード例 #4
0
ファイル: PostMappers.cs プロジェクト: lexTutor/BLOGITWebApp
 /// <summary>
 /// Edits the post Details and title of a post and returns the post
 /// </summary>
 /// <param name="post"></param>
 /// <param name="editedPost"></param>
 /// <returns></returns>
 public static Post MapToEditedPostView(Post post, OtherPostActivitiesPostVM editedPost)
 {
     post.PostDetails = editedPost.PostDetails;
     post.PostTitle   = editedPost.PostTitle;
     return(post);
 }