public async Task AddAsync(PostViewModel viewModel) { viewModel.Id = Guid.NewGuid(); var _post = _mapper.Map <Post>(viewModel); foreach (var tag in GetNewTags(viewModel.Tags)) { await _postTagRepository.AddAsync(new PostTag() { Post = _post, Tag = tag }); } foreach (var id in GetExistingTags(viewModel.Tags)) { await _postTagRepository.AddAsync(new PostTag() { Post = _post, TagId = id }); } if (await Commit()) { await RegisterLog(new EventLog(Guid.NewGuid(), viewModel.CreationDate, viewModel.CreatorUserId, null, null, JsonConvert.SerializeObject(viewModel), Type, "Add")); } }
public bool AddPostTag(PostTag postTag, bool IsSave) { return(_postTag.AddAsync(postTag, IsSave).Result); }