コード例 #1
0
ファイル: TagService.cs プロジェクト: michaelcanyon/CoffeeMap
 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));
 }
コード例 #2
0
 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));
         }
     }
 }
コード例 #3
0
 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));
 }
コード例 #4
0
        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));
            }
        }
コード例 #5
0
 public RoasterService(IRoasterRepository roasterRepository,
                       IRoasterTagRepository roasterTagRepository)
 {
     _roasterRepository    = roasterRepository ?? throw new ArgumentNullException(nameof(roasterRepository));
     _roasterTagRepository = roasterTagRepository ?? throw new ArgumentNullException(nameof(roasterTagRepository));
 }