public async Task CreateAsync(Guid id, string userId, string category, Location location, string description = null, IEnumerable <string> tags = null, Guid?groupId = null, decimal?price = null, string currency = null, DateTime?startDate = null, DateTime?endDate = null) { Logger.Debug($"Create remark, id:{id}, userId: {userId}, category: {category}, " + $"latitude: {location.Latitude}, longitude: {location.Longitude}."); var user = await _userRepository.GetOrFailAsync(userId); var remarkCategory = await _categoryRepository.GetByNameAsync(category); if (remarkCategory.HasNoValue) { throw new ServiceException(OperationCodes.CategoryNotFound, $"Category: '{category}' does not exist!"); } var encodedDescription = description.Empty() ? description : WebUtility.HtmlEncode(description); Group group = null; if (groupId != null) { group = await _groupRepository.GetOrFailAsync(groupId.Value); } var remark = new Remark(id, user, remarkCategory.Value, location, encodedDescription, group); if (price.HasValue) { remark.SetOffering(Offering.Create(price.Value, currency, startDate, endDate)); } if (tags == null || !tags.Any()) { await _remarkRepository.AddAsync(remark); return; } var availableTags = await _tagRepository.BrowseAsync(new BrowseTags { Results = 1000 }); if (availableTags.HasValue) { var selectedTags = availableTags.Value.Items .Select(x => x.Name) .Intersect(tags); foreach (var tag in selectedTags) { remark.AddTag(tag); } } await _remarkRepository.AddAsync(remark); }