public async Task<IList<RegisteredProducer>> FetchRegisteredProducersAsync(Scheme scheme, int year)
 {
     return await context
         .RegisteredProducers
         .Where(rp => rp.Scheme.Id == scheme.Id)
         .Where(rp => rp.ComplianceYear == year)
         .Where(rp => rp.CurrentSubmission != null)
         .Include(rp => rp.CurrentSubmission)
         .ToListAsync();
 }
        public MemberUpload(
            Guid organisationId,
            Scheme scheme,
            string data,
            string fileName)
        {
            Guard.ArgumentNotNull(() => scheme, scheme);

            OrganisationId = organisationId;
            Scheme = scheme;
            Errors = new List<MemberUploadError>();
            RawData = new MemberUploadRawData() { Data = data };
            FileName = fileName;
            ProducerSubmissions = new List<ProducerSubmission>();
        }
        public MemberUpload(
            Guid organisationId,
            string data,
            List<MemberUploadError> errors,
            decimal totalCharges,
            int? complianceYear,
            Scheme scheme,
            string fileName,
            string userId = null)
        {
            Guard.ArgumentNotNull(() => scheme, scheme);

            OrganisationId = organisationId;
            Scheme = scheme;
            Errors = errors;
            IsSubmitted = false;
            TotalCharges = totalCharges;
            ComplianceYear = complianceYear;
            RawData = new MemberUploadRawData() { Data = data };
            CreatedById = userId;
            FileName = fileName;
            ProducerSubmissions = new List<ProducerSubmission>();
        }
            private ProducerSubmission Build()
            {
                Scheme scheme = new Scheme(
                    A.Dummy<Guid>());

                var memberUpload = new MemberUpload(
                    A.Dummy<Guid>(),
                    A.Dummy<string>(),
                    A.Dummy<List<MemberUploadError>>(),
                    A.Dummy<decimal>(),
                    2017,
                    scheme,
                    A.Dummy<string>(),
                    A.Dummy<string>());

                var updatedDate = A.Dummy<DateTime>();

                RegisteredProducer registeredProducer = new RegisteredProducer(
                    registrationNumber,
                    2017,
                    scheme);

                ProducerSubmission producerSubmission = new ProducerSubmission(
                    registeredProducer,
                    memberUpload,
                    producerBusiness,
                    authorisedRepresentative,
                    updatedDate,
                    annualTurnover,
                    vatRegistered,
                    ceaseToExist,
                    tradingName,
                    eeePlacedOnMarketBandType,
                    sellingTechniqueType,
                    obligationType,
                    annualTurnOverBandType,
                    brandNames,
                    sicCodes,
                    chargeBandAmount,
                    (decimal)5.0);

                registeredProducer.SetCurrentSubmission(producerSubmission);

                return producerSubmission;
            }
            private void InstantiateProducerParameters()
            {
                TradingName = "Test trading name";

                scheme = A.Fake<Scheme>();

                MemberUpload = new MemberUpload(
                    A.Dummy<Guid>(),
                    A.Dummy<string>(),
                    A.Dummy<List<MemberUploadError>>(),
                    A.Dummy<decimal>(),
                    A.Dummy<int>(),
                    scheme,
                    A.Dummy<string>(),
                    A.Dummy<string>());

                ProducerCharges = new Dictionary<string, ProducerCharge>();
                ProducerCharges.Add(TradingName, new ProducerCharge() { ChargeBandAmount = new ChargeBandAmount() });

                GeneratedPrns = new Queue<string>();
                A.CallTo(() => DataAccess.ComputePrns(A<int>._)).Returns(GeneratedPrns);

                BrandNames = Enumerable.Empty<string>().ToArray();
                SicCodes = Enumerable.Empty<string>().ToArray();

                ProducerBusiness = new producerBusinessType()
                {
                    correspondentForNotices = new optionalContactDetailsContainerType() { },
                    Item = new companyType()
                    {
                        registeredOffice = new contactDetailsContainerType()
                        {
                            contactDetails = new contactDetailsType()
                            {
                                address = new addressType()
                                {
                                    country = countryType.UKENGLAND
                                }
                            }
                        }
                    }
                };

                AuthorisedRepresentative = null;

                EEEPlacedOnMarketBandType = eeePlacedOnMarketBandType.Lessthan5TEEEplacedonmarket;
                SellingTechnique = sellingTechniqueType.Both;
                ObligationType = obligationTypeType.Both;
                AnnualTurnoverBandType = annualTurnoverBandType.Greaterthanonemillionpounds;
                CeaseDate = null;
                RegistrationNumber = "TestRegistrationNumber";
                AnnualTurnover = 10;
                VatRegistered = false;
                Status = statusType.I;
            }