public async void IndexGet_GivenReturn_ViewModelShouldBeBuilt() { var returnId = Guid.NewGuid(); var aatfId = Guid.NewGuid(); var aatfName = "Test Aatf"; var aatfData = A.Fake <AatfData>(); var schemeId = Guid.NewGuid(); var schemeName = "Test Scheme"; var schemeInfo = A.Fake <SchemePublicInfo>(); var organisationId = Guid.NewGuid(); var @return = A.Fake <ReturnData>(); A.CallTo(() => @return.OrganisationData.Id).Returns(organisationId); A.CallTo(() => schemeInfo.Name).Returns(schemeName); A.CallTo(() => cache.FetchSchemePublicInfoBySchemeId(schemeId)).Returns(schemeInfo); A.CallTo(() => aatfData.Name).Returns(aatfName); A.CallTo(() => cache.FetchAatfData(@return.OrganisationData.Id, aatfId)).Returns(aatfData); A.CallTo(() => weeeClient.SendAsync(A <string> ._, A <GetReturn> .That.Matches(r => r.ReturnId.Equals(returnId)))).Returns(@return); var result = await controller.Index(returnId, aatfId, schemeId, ObligatedType.Received) as ViewResult; var viewModel = result.Model as ObligatedValuesCopyPasteViewModel; viewModel.AatfId.Should().Be(aatfId); viewModel.AatfName.Should().Be(aatfName); viewModel.OrganisationId.Should().Be(organisationId); viewModel.ReturnId.Should().Be(returnId); viewModel.SchemeId.Should().Be(schemeId); viewModel.SchemeName.Should().Be(schemeName); }
public virtual async Task <ActionResult> Index(Guid returnId, Guid aatfId, Guid schemeId, ObligatedType obligatedType) { using (var client = apiClient()) { var @return = await client.SendAsync(User.GetAccessToken(), new GetReturn(returnId, false)); var viewModel = new ObligatedValuesCopyPasteViewModel() { AatfId = aatfId, ReturnId = returnId, OrganisationId = @return.OrganisationData.Id, AatfName = (await cache.FetchAatfData(@return.OrganisationData.Id, aatfId)).Name, Type = obligatedType }; if (obligatedType == ObligatedType.Received) { viewModel.SchemeId = schemeId; viewModel.SchemeName = Task.Run(() => cache.FetchSchemePublicInfoBySchemeId(schemeId)).Result.Name; } await SetBreadcrumb(@return.OrganisationData.Id, BreadCrumbConstant.AatfReturn, aatfId, DisplayHelper.YearQuarterPeriodFormat(@return.Quarter, @return.QuarterWindow)); return(View(viewModel)); } }
private async Task SetBreadcrumb(Guid?schemeId, Guid?aatfId, Guid organisationId, FacilityType?facilityType) { if (schemeId.HasValue && !aatfId.HasValue) { breadcrumb.InternalActivity = InternalUserActivity.ManageScheme; breadcrumb.InternalScheme = await cache.FetchSchemeName(schemeId.Value); } if (!schemeId.HasValue && aatfId.HasValue) { switch (facilityType) { case FacilityType.Aatf: breadcrumb.InternalActivity = InternalUserActivity.ManageAatfs; breadcrumb.InternalAatf = (await cache.FetchAatfData(organisationId, aatfId.Value)).Name; break; case FacilityType.Ae: breadcrumb.InternalActivity = InternalUserActivity.ManageAes; breadcrumb.InternalAe = (await cache.FetchAatfData(organisationId, aatfId.Value)).Name; break; default: break; } } }
public async void IndexGet_GivenValidViewModel_BreadcrumbShouldBeSet() { var organisationId = Guid.NewGuid(); const string orgName = "orgName"; var @return = A.Fake <ReturnData>(); var quarterData = new Quarter(2019, QuarterType.Q1); var quarterWindow = QuarterWindowTestHelper.GetDefaultQuarterWindow(); var aatfInfo = A.Fake <AatfData>(); var aatfId = Guid.NewGuid(); const string reportingQuarter = "2019 Q1 Jan - Mar"; const string reportingPeriod = "Test (WEE/QW1234RE/ATF)"; @return.Quarter = quarterData; @return.QuarterWindow = quarterWindow; const string aatfName = "Test"; aatfInfo.ApprovalNumber = "WEE/QW1234RE/ATF"; A.CallTo(() => cache.FetchOrganisationName(organisationId)).Returns(orgName); A.CallTo(() => weeeClient.SendAsync(A <string> ._, A <GetReturn> ._)).Returns(@return); A.CallTo(() => cache.FetchAatfData(organisationId, aatfId)).Returns(aatfInfo); A.CallTo(() => aatfInfo.Name).Returns(aatfName); await controller.Index(organisationId, A.Dummy <Guid>(), aatfId, A.Dummy <Guid?>()); breadcrumb.ExternalActivity.Should().Be(BreadCrumbConstant.AatfReturn); breadcrumb.ExternalOrganisation.Should().Be(orgName); breadcrumb.OrganisationId.Should().Be(organisationId); Assert.Contains(reportingQuarter, breadcrumb.QuarterDisplayInfo); Assert.Contains(reportingPeriod, breadcrumb.AatfDisplayInfo); }
private async Task SetBreadcrumb(Guid organisationId, string activity, Guid aatfId, string quarter) { breadcrumb.ExternalOrganisation = await cache.FetchOrganisationName(organisationId); breadcrumb.ExternalActivity = activity; breadcrumb.OrganisationId = organisationId; var aatfInfo = await cache.FetchAatfData(organisationId, aatfId); breadcrumb.QuarterDisplayInfo = quarter; breadcrumb.AatfDisplayInfo = DisplayHelper.ReportingOnValue(aatfInfo.Name, aatfInfo.ApprovalNumber); }
public virtual async Task <ActionResult> Index(Guid organisationId, Guid returnId, Guid aatfId) { var viewModel = new ReusedOffSiteViewModel() { OrganisationId = organisationId, ReturnId = returnId, AatfId = aatfId, AatfName = (await cache.FetchAatfData(organisationId, aatfId)).Name }; using (var client = apiClient()) { var @return = await client.SendAsync(User.GetAccessToken(), new GetReturn(returnId, false)); await SetBreadcrumb(organisationId, BreadCrumbConstant.AatfReturn, aatfId, DisplayHelper.YearQuarterPeriodFormat(@return.Quarter, @return.QuarterWindow)); TempData["currentQuarter"] = @return.Quarter; TempData["currentQuarterWindow"] = @return.QuarterWindow; } return(View(viewModel)); }
public virtual async Task <ActionResult> Index(Guid organisationId, Guid returnId, Guid aatfId) { using (var client = apiClient()) { var weeeSentOn = await client.SendAsync(User.GetAccessToken(), new GetWeeeSentOn(aatfId, returnId, null)); var model = mapper.Map(new ReturnAndAatfToSentOnSummaryListViewModelMapTransfer() { WeeeSentOnDataItems = weeeSentOn, AatfId = aatfId, ReturnId = returnId, OrganisationId = organisationId, AatfName = (await cache.FetchAatfData(organisationId, aatfId)).Name }); var @return = await client.SendAsync(User.GetAccessToken(), new GetReturn(returnId, false)); await SetBreadcrumb(organisationId, BreadCrumbConstant.AatfReturn, aatfId, DisplayHelper.YearQuarterPeriodFormat(@return.Quarter, @return.QuarterWindow)); return(View(model)); } }
public async Task <ActionResult> Index(Guid returnId, Guid aatfId) { using (var client = apiClient()) { var schemeList = await client.SendAsync(User.GetAccessToken(), new GetReturnScheme(returnId)); var @return = await client.SendAsync(User.GetAccessToken(), new GetReturn(returnId, false)); var viewModel = mapper.Map(new ReturnAndSchemeDataToReceivedPcsViewModelMapTransfer() { AatfId = aatfId, ReturnId = returnId, OrganisationId = schemeList.OrganisationData.Id, AatfName = (await cache.FetchAatfData(schemeList.OrganisationData.Id, aatfId)).Name, ReturnData = @return, SchemeDataItems = schemeList.SchemeDataItems.ToList() }); await SetBreadcrumb(schemeList.OrganisationData.Id, BreadCrumbConstant.AatfReturn, aatfId, DisplayHelper.YearQuarterPeriodFormat(@return.Quarter, @return.QuarterWindow)); return(View(viewModel)); } }
public async Task GetEditRegisteredCompanyOrganisationDetails_GivenAatfId_BreadCrumbShouldBeSet() { var aatfId = Guid.NewGuid(); var organisationId = Guid.NewGuid(); var aatf = fixture.Build <AatfData>().WithAutoProperties().Create(); A.CallTo(() => cache.FetchAatfData(organisationId, aatfId)).Returns(aatf); await controller.EditRegisteredCompanyOrganisationDetails(A.Dummy <Guid>(), organisationId, aatfId, FacilityType.Aatf); breadcrumb.InternalActivity = InternalUserActivity.ManageAatfs; breadcrumb.InternalOrganisation = aatf.Name; }
public void Map_GivenOrganisationAndAatfId_CachedAatfNameShouldBeSet() { const string expected = "aatf"; var aatfData = A.Fake <AatfData>(); A.CallTo(() => aatfData.Name).Returns(expected); var transfer = new ReturnToObligatedViewModelMapTransfer() { OrganisationId = Guid.NewGuid(), AatfId = Guid.NewGuid() }; A.CallTo(() => cache.FetchAatfData(transfer.OrganisationId, transfer.AatfId)).Returns(aatfData); var result = mapper.Map(transfer); result.AatfName.Should().Be(expected); }
public ObligatedViewModel Map(ReturnToObligatedViewModelMapTransfer source) { Guard.ArgumentNotNull(() => source, source); var model = new ObligatedViewModel(new ObligatedCategoryValues(), calculator) { SchemeName = (source.SchemeId != new Guid()) ? Task.Run(() => cache.FetchSchemePublicInfoBySchemeId(source.SchemeId)).Result.Name : null, AatfName = Task.Run(() => cache.FetchAatfData(source.OrganisationId, source.AatfId)).Result.Name, AatfId = source.AatfId, OrganisationId = source.OrganisationId, ReturnId = source.ReturnId, SchemeId = source.SchemeId }; var transfer = new ObligatedDataToObligatedValueMapTransfer() { ObligatedCategoryValues = model.CategoryValues }; var existingData = new List <ObligatedCategoryValue>(); if (source.WeeeSentOnId != null) { model.WeeeSentOnId = source.WeeeSentOnId; } if (source.SchemeId != new Guid()) { transfer.WeeeDataValues = source.ReturnData.ObligatedWeeeReceivedData.Where(w => w.Aatf.Id == source.AatfId && w.Scheme.Id == source.SchemeId).ToList(); existingData = obligatedMap.Map(transfer).ToList(); } else if (source.SiteName != null) { transfer.WeeeDataValues = source.ReturnData.ObligatedWeeeSentOnData.Where(w => w.WeeeSentOnId == source.WeeeSentOnId).ToList(); existingData = obligatedMap.Map(transfer).ToList(); } else { transfer.WeeeDataValues = source.ReturnData.ObligatedWeeeReusedData.Where(w => w.Aatf.Id == source.AatfId).ToList(); existingData = obligatedMap.Map(transfer).ToList(); } if (source.SiteName != null) { model.SiteName = source.SiteName; } if (source.PastedData != null) { var obligatedPastedValues = new ObligatedPastedValues { B2B = pasteProcessor.BuildModel(source.PastedData.B2B), B2C = pasteProcessor.BuildModel(source.PastedData.B2C) }; model.CategoryValues = pasteProcessor.ParseObligatedPastedValues(obligatedPastedValues, existingData); } else { model.CategoryValues = existingData; } return(model); }