public async Task HandleAsync_GivenGetSentOnAatfSiteRequest_DataAccessIsCalled()
        {
            var weeeSentOnId = Guid.NewGuid();

            await handler.HandleAsync(new GetWeeeSentOnById(weeeSentOnId));

            A.CallTo(() => getSentOnAatfSiteDataAccess.GetWeeeSentOnById(weeeSentOnId)).MustHaveHappened(Repeated.Exactly.Once);
        }
Exemple #2
0
        public async Task <WeeeSentOnData> HandleAsync(GetWeeeSentOnById message)
        {
            authorization.EnsureCanAccessExternalArea();

            var weeeSentOnList = new List <WeeeSentOnData>();
            var weeeSentOn     = await getSentOnAatfSiteDataAccess.GetWeeeSentOnById(message.WeeeSentOnId);

            if (weeeSentOn == null)
            {
                return(null);
            }

            var amount = await fetchWeeeSentOnAmountDataAccess.FetchObligatedWeeeSentOnForReturn(weeeSentOn.Id);

            var weeeSentOnObligatedData = amount.Select(n => new WeeeObligatedData(n.Id, new AatfData(n.WeeeSentOn.Aatf.Id, n.WeeeSentOn.Aatf.Name, n.WeeeSentOn.Aatf.ApprovalNumber, n.WeeeSentOn.Aatf.ComplianceYear), n.CategoryId, n.NonHouseholdTonnage, n.HouseholdTonnage)).ToList();

            var weeeSentOnData = new WeeeSentOnData()
            {
                SiteAddress   = addressMapper.Map(weeeSentOn.SiteAddress),
                Tonnages      = weeeSentOnObligatedData,
                WeeeSentOnId  = weeeSentOn.Id,
                SiteAddressId = weeeSentOn.SiteAddress.Id
            };

            if (weeeSentOn.OperatorAddress != null)
            {
                weeeSentOnData.OperatorAddress   = addressMapper.Map(weeeSentOn.OperatorAddress);
                weeeSentOnData.OperatorAddressId = weeeSentOn.OperatorAddress.Id;
            }

            return(weeeSentOnData);
        }