public async Task <Post> MakeAsync(PostCreateDto model) { model.CheckArgumentIsNull(); var post = model.Adapt <Post>(); post.CreateDate = post.ModifyDate = _dateService.UtcNow(); post.CreatorUserId = _userContext.UserId; post.WebsiteId = _userContext.WebsiteId; if (string.IsNullOrWhiteSpace(model.Slug)) { post.Slug = model.Title; } post.Slug = post.Slug.MakeSlug(); if (post.Status == PostStatus.Published || post.Status == PostStatus.Planned) { post.PublishDate = model.PublishDate; } else { post.PublishDate = null; } if (!model.Tags.IsNullOrEmpty()) { foreach (var tag in model.Tags.Split(',')) { var existingTag = await _tagRepository.GetByTitleAsync(tag, _websiteInfo.Id); if (existingTag != null) { post.PostTags.Add(new PostTag { TagId = existingTag.Id }); } else { var newTag = await _tagFactory.MakeAsync(tag); await _tagRepository.AddAndSaveAsync(newTag); post.PostTags.Add(new PostTag { TagId = newTag.Id }); } } } return(post); }