Example #1
0
        public async Task <Guid> HandleAsync(EditSentOnAatfSiteWithOperator message)
        {
            authorization.EnsureCanAccessExternalArea();

            var sentOn = await genericDataAccess.GetById <WeeeSentOn>((Guid)message.WeeeSentOnId);

            Country operatorCountry = await organisationDetailsDataAccess.FetchCountryAsync(message.OperatorAddressData.CountryId);

            var operatorAddress = new AatfAddress(
                message.OperatorAddressData.Name,
                message.OperatorAddressData.Address1,
                message.OperatorAddressData.Address2,
                message.OperatorAddressData.TownOrCity,
                message.OperatorAddressData.CountyOrRegion,
                message.OperatorAddressData.Postcode,
                operatorCountry);

            await sentOnDataAccess.UpdateWithOperatorAddress(sentOn, operatorAddress);

            return(sentOn.Id);
        }
Example #2
0
        public async Task HandleAsync_GivenEditSentOnAatfSiteWithOperatorRequest_DataAccessIsCalled()
        {
            var request = new EditSentOnAatfSiteWithOperator()
            {
                WeeeSentOnId        = Guid.NewGuid(),
                OperatorAddressData = new OperatorAddressData()
                {
                    Name           = "OpName",
                    Address1       = "Address1",
                    Address2       = "Address2",
                    TownOrCity     = "Town",
                    CountyOrRegion = "County",
                    Postcode       = "GU22 7UY",
                    CountryId      = Guid.NewGuid()
                }
            };

            var weeeSentOn = new WeeeSentOn();
            var country    = new Country(A.Dummy <Guid>(), A.Dummy <string>());

            A.CallTo(() => genericDataAccess.GetById <WeeeSentOn>((Guid)request.WeeeSentOnId)).Returns(weeeSentOn);
            A.CallTo(() => orgDataAccess.FetchCountryAsync(request.OperatorAddressData.CountryId)).Returns(country);

            var operatorAddress = new AatfAddress(
                request.OperatorAddressData.Name,
                request.OperatorAddressData.Address1,
                request.OperatorAddressData.Address2,
                request.OperatorAddressData.TownOrCity,
                request.OperatorAddressData.CountyOrRegion,
                request.OperatorAddressData.Postcode,
                country);

            await handler.HandleAsync(request);

            A.CallTo(() => sentOnDataAccess.UpdateWithOperatorAddress(weeeSentOn, operatorAddress)).WhenArgumentsMatch(p => p.Get <AatfAddress>("request").Address1 == operatorAddress.Address1);
        }