예제 #1
0
        public async Task HttpPost_ConfirmRemoval_WithYesOptionSelected_AndRequestReturnsCacheInvalidation_ShouldInvalidateProducerSearch()
        {
            var viewModel = new ConfirmRemovalViewModel {
                SelectedValue = "Yes"
            };

            A.CallTo(() => weeeClient.SendAsync(A <string> ._, A <RemoveProducer> ._))
            .Returns(new RemoveProducerResult(true));

            await ProducersController().ConfirmRemoval(A.Dummy <Guid>(), viewModel);

            A.CallTo(() => cache.InvalidateProducerSearch())
            .MustHaveHappened(Repeated.Exactly.Once);
        }
예제 #2
0
        public async Task <ActionResult> ConfirmRemoval(Guid registeredProducerId, ConfirmRemovalViewModel model)
        {
            await SetBreadcrumb();

            ProducerDetailsScheme producerDetailsScheme = await FetchProducerDetailsScheme(registeredProducerId);

            if (!ModelState.IsValid)
            {
                return(View(new ConfirmRemovalViewModel
                {
                    Producer = producerDetailsScheme
                }));
            }

            if (model.SelectedValue == "Yes")
            {
                RemoveProducerResult result;
                using (IWeeeClient client = apiClient())
                {
                    result = await client.SendAsync(User.GetAccessToken(), new RemoveProducer(registeredProducerId));
                }

                if (result.InvalidateProducerSearchCache)
                {
                    await cache.InvalidateProducerSearch();
                }

                return(RedirectToAction("Removed",
                                        new
                {
                    producerDetailsScheme.RegistrationNumber,
                    producerDetailsScheme.ComplianceYear,
                    producerDetailsScheme.SchemeName
                }));
            }
            else
            {
                return(RedirectToAction("Details",
                                        new
                {
                    producerDetailsScheme.RegistrationNumber
                }));
            }
        }
예제 #3
0
        public async Task <ActionResult> Index(FormCollection form)
        {
            await cache.InvalidateProducerSearch();

            return(View("CacheCleared"));
        }