public async Task <IActionResult> Edit(PostAdminEditViewModel inputModel)
        {
            if (!this.ModelState.IsValid)
            {
                return(this.View(inputModel));
            }

            await this.postsService.EditPostAsync(inputModel);

            return(this.RedirectToAction("All"));
        }
        public async Task EditPostAsync(PostAdminEditViewModel inputModel)
        {
            if (!this.dbContext.Users.Any(u => u.Id == inputModel.AuthorId))
            {
                throw new ArgumentNullException(string.Format(ServicesConstants.InvalidUserId, inputModel.AuthorId));
            }

            if (!this.dbContext.BlogCategories.Any(u => u.Id == inputModel.CategoryId))
            {
                throw new ArgumentNullException(string.Format(ServicesConstants.InvalidPostCategoryId, inputModel.CategoryId));
            }

            var post = await this.dbContext.Post
                       .Include(p => p.Category)
                       .FirstOrDefaultAsync(p => p.Id == inputModel.Id);

            if (post == null)
            {
                throw new ArgumentNullException(string.Format(ServicesConstants.InvalidPostId, inputModel.Id));
            }

            Enum.TryParse(inputModel.Type, true, out CategoryType postType);

            post.IsDeleted = inputModel.IsDeleted;

            post.DeletedOn = inputModel.DeletedOn;

            post.CreatedOn = inputModel.CreatedOn;

            post.ModifiedOn = inputModel.ModifiedOn;

            post.Title = inputModel.Title;

            post.Description = inputModel.Description;

            post.AuthorId = inputModel.AuthorId;

            post.CategoryId = inputModel.CategoryId;

            post.Category.Name = inputModel.CategoryName;

            post.Rating = inputModel.Rating;

            post.Type = postType;

            post.VideoUrl = inputModel.VideoUrl;

            post.IsPublic = inputModel.IsPublic;

            this.dbContext.Update(post);

            await this.dbContext.SaveChangesAsync();
        }