static async Task Main(string[] args) { using (ApplicationDbContext ctx = new ApplicationDbContext()) { ctx.Database.EnsureCreated(); ctx.Licences.Add(new Licence() { UserName = "******", ValidUntil = new DateTime(2021, 12, 31) }); ctx.Licences.Add(new Licence() { UserName = "******", ValidUntil = new DateTime(2021, 12, 31) }); ctx.Licences.Add(new Licence() { UserName = "******", ValidUntil = new DateTime(2018, 12, 31) }); await ctx.SaveChangesAsync(); LicenceRepository licenceRepository = new LicenceRepository(ctx); foreach (Licence licence in await licenceRepository.GetCurrentValidLicencesAsync()) { Console.WriteLine(licence); } } }
public PublicRegisterProfile() { CreateMap <Licence, PublicRegisterLicenceSummaryViewModel>() .ForMember(x => x.Id, opt => opt.MapFrom(y => y.Id)) .ForMember(x => x.ApplicationId, opt => opt.MapFrom(y => y.ApplicationId)) .ForMember(x => x.MostRecentStatus, opt => opt.MapFrom(y => StatusProfile.MapLicenceStatusViewModel(LicenceRepository.GetLatestStatus(y)))) .ForMember(x => x.BusinessName, opt => opt.MapFrom(y => y.BusinessName)) .ForMember(x => x.TradingName, opt => opt.MapFrom(y => y.TradingName)) .ForMember(x => x.CountryId, opt => opt.MapFrom(y => y.Address.CountryId)) .ForMember(x => x.CountyId, opt => opt.MapFrom(y => y.Address.CountyId)) .ForMember(x => x.IsApplication, opt => opt.MapFrom(y => LicenceRepository.GetLatestStatus(y).Status.IsApplication)) .ForAllOtherMembers(opt => opt.Ignore()); CreateMap <Licence, PublicRegisterLicenceDetailViewModel>() .ForMember(x => x.Id, opt => opt.MapFrom(y => y.Id)) .ForMember(x => x.ApplicationId, opt => opt.MapFrom(y => y.ApplicationId)) .ForMember(x => x.MostRecentStatus, opt => opt.MapFrom(y => StatusProfile.MapLicenceStatusViewModel(LicenceRepository.GetLatestStatus(y)))) .ForMember(x => x.MostRecentLicenceIssuedStatus, opt => opt.MapFrom(y => StatusProfile.MapLicenceStatusViewModel(LicenceRepository.GetLatestLicenceIssueStatus(y)))) .ForMember(x => x.MostRecentLicenceSubmittedStatus, opt => opt.MapFrom(y => StatusProfile.MapLicenceStatusViewModel(LicenceRepository.GetLatestLicenceSubmissionStatus(y)))) .ForMember(x => x.BusinessName, opt => opt.MapFrom(y => y.BusinessName)) .ForMember(x => x.TradingName, opt => opt.MapFrom(y => y.TradingName)) .ForMember(x => x.IsApplication, opt => opt.MapFrom(y => LicenceRepository.GetLatestStatus(y).Status.IsApplication)) .ForMember(x => x.Address, opt => opt.MapFrom(y => y.Address)) .ForMember(x => x.BusinessPhoneNumber, opt => opt.MapFrom(y => y.BusinessPhoneNumber)) .ForMember(x => x.BusinessType, opt => opt.MapFrom(y => y.LegalStatus)) .ForMember(x => x.OperatingCountries, opt => opt.MapFrom(y => y.OperatingCountries)) .ForMember(x => x.PrincipalAuthorities, opt => opt.MapFrom(y => y.PrincipalAuthorities)) .ForMember(x => x.OperatingIndustries, opt => opt.MapFrom(y => y.OperatingIndustries)) .ForMember(x => x.NamedIndividuals, opt => opt.MapFrom(y => y.NamedIndividuals)) .ForMember(x => x.NamedPosts, opt => opt.MapFrom(y => y.NamedJobTitles)) .ForAllOtherMembers(opt => opt.Ignore()); }
public AdminController(CityRepository cityRepository, TeamRepository teamRepository, LicenceRepository licenceRepository, RefereeRepository refereeRepository, GameRepository gameRepository) { _cityRepository = cityRepository; _teamRepository = teamRepository; _licenceRepository = licenceRepository; _refereeRepository = refereeRepository; _gameRepository = gameRepository; }
public PublicRegisterLicenceDetailViewModel BuildLicence(int id) { var licence = _licenceRepository.GetById(id); return(LicenceRepository.GetLatestStatus(licence).Status.IsLicence ? BuildDetail(licence) : null); }