public TagService(ITagRepository tagRepository, IRoasterTagRepository roasterTagRepository, ILogger logger) { _tagRepository = tagRepository ?? throw new ArgumentNullException(nameof(tagRepository)); _roasterTagRepository = roasterTagRepository ?? throw new ArgumentNullException(nameof(tagRepository)); _logger = logger ?? throw new ArgumentNullException(nameof(logger)); }
public static void BuildRoasterTags(IList <Tag> tags, Guid roasterId, IRoasterTagRepository roasterTagRepository) { if (tags != null) { foreach (var item in tags) { roasterTagRepository.Add(new RoasterTag(roasterId, item.Id)); } } }
public RoasterAdminService(IRoasterRepository roasterRepository, IPictureRepository pictureRepository, IRoasterTagRepository roasterTagRepository, ITagRepository tagRepository, IAddressRepository addressRepository, ILogger logger) { _roasterRepository = roasterRepository ?? throw new ArgumentNullException(nameof(roasterRepository)); _roasterTagRepository = roasterTagRepository ?? throw new ArgumentNullException(nameof(roasterTagRepository)); _pictureRepository = pictureRepository ?? throw new ArgumentNullException(nameof(pictureRepository)); _tagRepository = tagRepository ?? throw new ArgumentNullException(nameof(tagRepository)); _addressReposiotry = addressRepository ?? throw new ArgumentNullException(nameof(addressRepository)); _logger = logger ?? throw new ArgumentNullException(nameof(addressRepository)); }
public static async Task UpdateRoasterTagsAsync(string tags, ITagRepository tagRepository, IRoasterTagRepository roasterTagRepository, Guid roasterId) { //TODO: check if it's work var tagsList = await BuildTagsListAsync(tags, tagRepository); var tagsIds = (await roasterTagRepository.GetPairsByRoasterIdAsNoTrackingAsync(roasterId)).Select(p => p.TagId); var tagsToAdd = tagsList.Where(t => !tagsIds.Contains(t.Id)).ToList(); var tagsToDelete = tagsIds.Except(tagsList.Select(t => t.Id).ToList()).ToList(); foreach (var i in tagsToAdd) { roasterTagRepository.Add(new RoasterTag(roasterId, i.Id)); } foreach (var i in tagsToDelete) { roasterTagRepository.Delete(new RoasterTag(roasterId, i)); } }
public RoasterService(IRoasterRepository roasterRepository, IRoasterTagRepository roasterTagRepository) { _roasterRepository = roasterRepository ?? throw new ArgumentNullException(nameof(roasterRepository)); _roasterTagRepository = roasterTagRepository ?? throw new ArgumentNullException(nameof(roasterTagRepository)); }