public async Task <PersonLicensePrice> GetCompetititonTemporaryLicensePriceAsync(Competition competition, Gender gender, DateTime birthDate) { var expert = calculatorManager.Find(competition.Discipline); if (expert == null) { throw new InvalidDisciplineException(); } var age = birthDate.Age(); return(await LicensesWorkflow.GetPersonLicensePriceAsync(competition.LicenseIssuerId, competition.Discipline, gender, age, PersonLicenseFlags.TemporaryLicense)); }
public CompetitionsWorkflow(ICompetitionContext context, IDisciplineCalculatorManager calculatorManager, IDistanceDisciplineExpertManager distanceExpertManager, IEventRecorder recorder) { this.context = context; this.calculatorManager = calculatorManager; this.recorder = recorder; this.distanceExpertManager = distanceExpertManager; DistancesWorkflow = new DistancesWorkflow(context, calculatorManager, distanceExpertManager, recorder); DistanceCombinationsWorkflow = new DistanceCombinationsWorkflow(context, recorder); LicensesWorkflow = new LicensesWorkflow(context, calculatorManager, recorder); RacesWorkflow = new RacesWorkflow(context, distanceExpertManager, recorder); }
protected virtual void Dispose(bool disposing) { if (!isDisposed) { if (disposing) { DistancesWorkflow.Dispose(); DistanceCombinationsWorkflow.Dispose(); LicensesWorkflow.Dispose(); RacesWorkflow.Dispose(); context.Dispose(); } isDisposed = true; } }
public async Task <PersonLicensePrice> GetCompetitionLicenseRenewalPriceAsync(Competition competition, PersonLicense license) { if (!IsLicenseExpired(license, competition) && !license.Flags.HasFlag(PersonLicenseFlags.TemporaryLicense)) { return(null); } var expert = calculatorManager.Find(competition.Discipline); if (expert == null) { throw new InvalidDisciplineException(); } var age = license.Flags.HasFlag(PersonLicenseFlags.TemporaryLicense) ? license.Person.BirthDate.Age() : expert.SeasonAge(expert.Season(competition.Starts), license.Person.BirthDate); return(await LicensesWorkflow.GetPersonLicensePriceAsync(competition.LicenseIssuerId, competition.Discipline, license.Person.Gender, age, license.Flags)); }
public async Task <PersonCompetitor> AddNewCompetitorAsync(Competition competition, Guid listId, PersonLicense license, CompetitorStatus status, CompetitorSource source) { await context.LoadAsync(license, l => l.Club); var @class = await LicensesWorkflow.GetPersonLicenseVenueClassAsync(license, competition.VenueCode, competition.Discipline, competition.Starts); var competitor = new PersonCompetitor { ListId = listId, Person = license.Person, Name = license.Person.Name, ShortName = new string(license.Person.Name.PrefixedSurname.Take(50).ToArray()), LicenseDiscipline = license.Discipline, LicenseKey = license.Key, LicenseFlags = license.Flags, Gender = license.Person.Gender, Status = status, Category = license.Category, Class = @class, Sponsor = license.Sponsor, ClubCountryCode = license.ClubCountryCode, ClubCode = license.ClubCode, ClubShortName = license.Club?.ShortName, ClubFullName = license.Club?.FullName, From = license.Person.Address.City, StartNumber = license.Number ?? 0, NationalityCode = license.Person.NationalityCode, VenueCode = license.VenueCode, Transponder1 = license.Transponder1, Transponder2 = license.Transponder2, Source = source }; await AddCompetitorAsync(competition, competitor); return(competitor); }