예제 #1
0
        public async Task <DownParty> GetDownPartyByNameAsync(Party.IdKey idKey, bool required = true)
        {
            if (idKey == null)
            {
                new ArgumentNullException(nameof(idKey));
            }

            return(await ReadItemAsync <DownParty>(await DownParty.IdFormatAsync(idKey), DataDocument.PartitionIdFormat(idKey), required));
        }
예제 #2
0
        private async Task <DownParty> GetDownPartyAsync(ITenantRepository tenantRepository, Track.IdKey trackIdKey, Group downPartyGroup, bool acceptUnknownParty)
        {
            var downPartyIdKey = new Party.IdKey
            {
                TenantName = trackIdKey.TenantName,
                TrackName  = trackIdKey.TrackName,
                PartyName  = downPartyGroup.Value,
            };

            try
            {
                return(await tenantRepository.GetDownPartyByNameAsync(downPartyIdKey, required : !acceptUnknownParty));
            }
            catch (Exception ex)
            {
                throw new RouteCreationException($"Invalid tenantName '{downPartyIdKey.TenantName}', trackName '{downPartyIdKey.TrackName}' and downPartyName '{downPartyIdKey.PartyName}'.", ex);
            }
        }
예제 #3
0
        private async Task <UpParty> GetUpPartyAsync(ITenantRepository tenantRepository, Track.IdKey trackIdKey, Group upPartyGroup)
        {
            var upPartyIdKey = new Party.IdKey
            {
                TenantName = trackIdKey.TenantName,
                TrackName  = trackIdKey.TrackName,
                PartyName  = upPartyGroup.Value,
            };

            try
            {
                return(await tenantRepository.GetUpPartyByNameAsync(upPartyIdKey));
            }
            catch (Exception ex)
            {
                throw new RouteCreationException($"Invalid tenantName '{upPartyIdKey.TenantName}', trackName '{upPartyIdKey.TrackName}' and upPartyName '{upPartyIdKey.PartyName}'.", ex);
            }
        }
예제 #4
0
        private async Task <List <UpPartyLink> > GetAllowedToUpPartyIds(TelemetryScopedLogger scopedLogger, Track.IdKey trackIdKey, Group toUpPartyGroup, DownParty downParty)
        {
            var toUpParties = new List <UpPartyLink>();

            if (toUpPartyGroup.Captures.Count > 5)
            {
                throw new ArgumentException($"More then 5 to up-party for down-party '{downParty.Id}'.");
            }

            foreach (Capture upPartyCapture in toUpPartyGroup.Captures)
            {
                var toUpPartyIdKey = new Party.IdKey
                {
                    TenantName = trackIdKey.TenantName,
                    TrackName  = trackIdKey.TrackName,
                    PartyName  = upPartyCapture.Value,
                };
                await toUpPartyIdKey.ValidateObjectAsync();

                var allowUpParty = downParty.AllowUpParties.Where(ap => ap.Name == toUpPartyIdKey.PartyName).SingleOrDefault();
                if (allowUpParty != null)
                {
                    toUpParties.Add(allowUpParty);
                }
                else
                {
                    try
                    {
                        throw new ArgumentException($"Up-party name '{toUpPartyIdKey.PartyName}' not allowed for down-party '{downParty.Id}',");
                    }
                    catch (Exception ex)
                    {
                        scopedLogger.Warning(ex);
                    }
                }
            }

            if (toUpParties.Count() > 1)
            {
                throw new NotSupportedException("Currently only 0 and 1 to up-party is supported.");
            }
            return(toUpParties);
        }
예제 #5
0
 public Task <DownParty> GetDownPartyByNameAsync(Party.IdKey idKey, bool requered = true)
 {
     throw new NotImplementedException();
 }