diff --git a/Sources/AssemblyVersionAuto.cs b/Sources/AssemblyVersionAuto.cs index 425ebf97..f8b527b1 100644 --- a/Sources/AssemblyVersionAuto.cs +++ b/Sources/AssemblyVersionAuto.cs @@ -3,6 +3,6 @@ [assembly: AssemblyCopyright("Copyright ? 2019 Episerver")] -[assembly: AssemblyVersion("13.9.0.0")] -[assembly: AssemblyInformationalVersion("13.9.0")] -[assembly: AssemblyFileVersion("13.9.0.3821")] +[assembly: AssemblyVersion("13.10.0.0")] +[assembly: AssemblyInformationalVersion("13.10.0")] +[assembly: AssemblyFileVersion("13.10.0.3843")] diff --git a/Sources/EPiServer.Reference.Commerce.Manager/EPiServer.Reference.Commerce.Manager.csproj b/Sources/EPiServer.Reference.Commerce.Manager/EPiServer.Reference.Commerce.Manager.csproj index 690e8c22..d4e345fd 100644 --- a/Sources/EPiServer.Reference.Commerce.Manager/EPiServer.Reference.Commerce.Manager.csproj +++ b/Sources/EPiServer.Reference.Commerce.Manager/EPiServer.Reference.Commerce.Manager.csproj @@ -376,109 +376,109 @@ --> - ..\..\packages\EPiServer.Commerce.Core.13.9.0\lib\net461\EPiServer.Business.Commerce.dll + ..\..\packages\EPiServer.Commerce.Core.13.10.0\lib\net461\EPiServer.Business.Commerce.dll True - ..\..\packages\EPiServer.Commerce.Core.13.9.0\lib\net461\EPiServer.Commerce.Reporting.dll + ..\..\packages\EPiServer.Commerce.Core.13.10.0\lib\net461\EPiServer.Commerce.Reporting.dll True - ..\..\packages\EPiServer.Commerce.Core.13.9.0\lib\net461\EPiServer.Commerce.Internal.Migration.dll + ..\..\packages\EPiServer.Commerce.Core.13.10.0\lib\net461\EPiServer.Commerce.Internal.Migration.dll True - ..\..\packages\EPiServer.Commerce.Core.13.9.0\lib\net461\Mediachase.BusinessFoundation.dll + ..\..\packages\EPiServer.Commerce.Core.13.10.0\lib\net461\Mediachase.BusinessFoundation.dll True - ..\..\packages\EPiServer.Commerce.Core.13.9.0\lib\net461\Mediachase.BusinessFoundation.Data.dll + ..\..\packages\EPiServer.Commerce.Core.13.10.0\lib\net461\Mediachase.BusinessFoundation.Data.dll True - ..\..\packages\EPiServer.Commerce.Core.13.9.0\lib\net461\Mediachase.Commerce.dll + ..\..\packages\EPiServer.Commerce.Core.13.10.0\lib\net461\Mediachase.Commerce.dll True - ..\..\packages\EPiServer.Commerce.Core.13.9.0\lib\net461\Mediachase.Commerce.Marketing.Validators.dll + ..\..\packages\EPiServer.Commerce.Core.13.10.0\lib\net461\Mediachase.Commerce.Marketing.Validators.dll True - ..\..\packages\EPiServer.Commerce.Core.13.9.0\lib\net461\Mediachase.Commerce.Plugins.Payment.dll + ..\..\packages\EPiServer.Commerce.Core.13.10.0\lib\net461\Mediachase.Commerce.Plugins.Payment.dll True - ..\..\packages\EPiServer.Commerce.Core.13.9.0\lib\net461\Mediachase.Commerce.Plugins.Shipping.dll + ..\..\packages\EPiServer.Commerce.Core.13.10.0\lib\net461\Mediachase.Commerce.Plugins.Shipping.dll True - ..\..\packages\EPiServer.Commerce.Core.13.9.0\lib\net461\Mediachase.Commerce.Website.dll + ..\..\packages\EPiServer.Commerce.Core.13.10.0\lib\net461\Mediachase.Commerce.Website.dll True - ..\..\packages\EPiServer.Commerce.Core.13.9.0\lib\net461\Mediachase.Commerce.Workflow.dll + ..\..\packages\EPiServer.Commerce.Core.13.10.0\lib\net461\Mediachase.Commerce.Workflow.dll True - ..\..\packages\EPiServer.Commerce.Core.13.9.0\lib\net461\Mediachase.DataProvider.dll + ..\..\packages\EPiServer.Commerce.Core.13.10.0\lib\net461\Mediachase.DataProvider.dll True - ..\..\packages\EPiServer.Commerce.Core.13.9.0\lib\net461\Mediachase.FileUploader.dll + ..\..\packages\EPiServer.Commerce.Core.13.10.0\lib\net461\Mediachase.FileUploader.dll True - ..\..\packages\EPiServer.Commerce.Core.13.9.0\lib\net461\Mediachase.MetaDataPlus.dll + ..\..\packages\EPiServer.Commerce.Core.13.10.0\lib\net461\Mediachase.MetaDataPlus.dll True - ..\..\packages\EPiServer.Commerce.Core.13.9.0\lib\net461\Mediachase.Search.dll + ..\..\packages\EPiServer.Commerce.Core.13.10.0\lib\net461\Mediachase.Search.dll True - ..\..\packages\EPiServer.Commerce.Core.13.9.0\lib\net461\Mediachase.Search.Extensions.dll + ..\..\packages\EPiServer.Commerce.Core.13.10.0\lib\net461\Mediachase.Search.Extensions.dll True - ..\..\packages\EPiServer.Commerce.Core.13.9.0\lib\net461\Mediachase.Search.LuceneSearchProvider.dll + ..\..\packages\EPiServer.Commerce.Core.13.10.0\lib\net461\Mediachase.Search.LuceneSearchProvider.dll True - ..\..\packages\EPiServer.Commerce.Core.13.9.0\lib\net461\Mediachase.SqlDataProvider.dll + ..\..\packages\EPiServer.Commerce.Core.13.10.0\lib\net461\Mediachase.SqlDataProvider.dll True - ..\..\packages\EPiServer.Commerce.Core.13.9.0\lib\net461\Mediachase.WebConsoleLib.dll + ..\..\packages\EPiServer.Commerce.Core.13.10.0\lib\net461\Mediachase.WebConsoleLib.dll True - ..\..\packages\EPiServer.CommerceManager.13.9.0\lib\net461\Mediachase.ConsoleManager.dll + ..\..\packages\EPiServer.CommerceManager.13.10.0\lib\net461\Mediachase.ConsoleManager.dll True - ..\..\packages\EPiServer.Commerce.Core.13.9.0\lib\net461\AjaxControlToolkit.dll + ..\..\packages\EPiServer.Commerce.Core.13.10.0\lib\net461\AjaxControlToolkit.dll True - ..\..\packages\EPiServer.CommerceManager.13.9.0\lib\net461\ComponentArt.Web.UI.dll + ..\..\packages\EPiServer.CommerceManager.13.10.0\lib\net461\ComponentArt.Web.UI.dll True - ..\..\packages\EPiServer.CommerceManager.13.9.0\lib\net461\RssToolkit.dll + ..\..\packages\EPiServer.CommerceManager.13.10.0\lib\net461\RssToolkit.dll True - ..\..\packages\EPiServer.CommerceManager.13.9.0\lib\net461\Validators.dll + ..\..\packages\EPiServer.CommerceManager.13.10.0\lib\net461\Validators.dll True - + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - + diff --git a/Sources/EPiServer.Reference.Commerce.Manager/packages.config b/Sources/EPiServer.Reference.Commerce.Manager/packages.config index e9afaebd..63f821fa 100644 --- a/Sources/EPiServer.Reference.Commerce.Manager/packages.config +++ b/Sources/EPiServer.Reference.Commerce.Manager/packages.config @@ -45,6 +45,6 @@ - - + + diff --git a/Sources/EPiServer.Reference.Commerce.Manager/web.config b/Sources/EPiServer.Reference.Commerce.Manager/web.config index 22974408..f8470e76 100644 --- a/Sources/EPiServer.Reference.Commerce.Manager/web.config +++ b/Sources/EPiServer.Reference.Commerce.Manager/web.config @@ -540,79 +540,79 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + diff --git a/Sources/EPiServer.Reference.Commerce.Shared/EPiServer.Reference.Commerce.Shared.csproj b/Sources/EPiServer.Reference.Commerce.Shared/EPiServer.Reference.Commerce.Shared.csproj index 62d05448..5d4bef73 100644 --- a/Sources/EPiServer.Reference.Commerce.Shared/EPiServer.Reference.Commerce.Shared.csproj +++ b/Sources/EPiServer.Reference.Commerce.Shared/EPiServer.Reference.Commerce.Shared.csproj @@ -267,79 +267,79 @@ --> - ..\..\packages\EPiServer.Commerce.Core.13.9.0\lib\net461\EPiServer.Business.Commerce.dll + ..\..\packages\EPiServer.Commerce.Core.13.10.0\lib\net461\EPiServer.Business.Commerce.dll True - ..\..\packages\EPiServer.Commerce.Core.13.9.0\lib\net461\EPiServer.Commerce.Internal.Migration.dll + ..\..\packages\EPiServer.Commerce.Core.13.10.0\lib\net461\EPiServer.Commerce.Internal.Migration.dll True - ..\..\packages\EPiServer.Commerce.Core.13.9.0\lib\net461\Mediachase.BusinessFoundation.dll + ..\..\packages\EPiServer.Commerce.Core.13.10.0\lib\net461\Mediachase.BusinessFoundation.dll True - ..\..\packages\EPiServer.Commerce.Core.13.9.0\lib\net461\Mediachase.BusinessFoundation.Data.dll + ..\..\packages\EPiServer.Commerce.Core.13.10.0\lib\net461\Mediachase.BusinessFoundation.Data.dll True - ..\..\packages\EPiServer.Commerce.Core.13.9.0\lib\net461\Mediachase.Commerce.dll + ..\..\packages\EPiServer.Commerce.Core.13.10.0\lib\net461\Mediachase.Commerce.dll True - ..\..\packages\EPiServer.Commerce.Core.13.9.0\lib\net461\Mediachase.Commerce.Marketing.Validators.dll + ..\..\packages\EPiServer.Commerce.Core.13.10.0\lib\net461\Mediachase.Commerce.Marketing.Validators.dll True - ..\..\packages\EPiServer.Commerce.Core.13.9.0\lib\net461\Mediachase.Commerce.Plugins.Payment.dll + ..\..\packages\EPiServer.Commerce.Core.13.10.0\lib\net461\Mediachase.Commerce.Plugins.Payment.dll True - ..\..\packages\EPiServer.Commerce.Core.13.9.0\lib\net461\Mediachase.Commerce.Plugins.Shipping.dll + ..\..\packages\EPiServer.Commerce.Core.13.10.0\lib\net461\Mediachase.Commerce.Plugins.Shipping.dll True - ..\..\packages\EPiServer.Commerce.Core.13.9.0\lib\net461\Mediachase.Commerce.Website.dll + ..\..\packages\EPiServer.Commerce.Core.13.10.0\lib\net461\Mediachase.Commerce.Website.dll True - ..\..\packages\EPiServer.Commerce.Core.13.9.0\lib\net461\Mediachase.Commerce.Workflow.dll + ..\..\packages\EPiServer.Commerce.Core.13.10.0\lib\net461\Mediachase.Commerce.Workflow.dll True - ..\..\packages\EPiServer.Commerce.Core.13.9.0\lib\net461\Mediachase.DataProvider.dll + ..\..\packages\EPiServer.Commerce.Core.13.10.0\lib\net461\Mediachase.DataProvider.dll True - ..\..\packages\EPiServer.Commerce.Core.13.9.0\lib\net461\Mediachase.FileUploader.dll + ..\..\packages\EPiServer.Commerce.Core.13.10.0\lib\net461\Mediachase.FileUploader.dll True - ..\..\packages\EPiServer.Commerce.Core.13.9.0\lib\net461\Mediachase.MetaDataPlus.dll + ..\..\packages\EPiServer.Commerce.Core.13.10.0\lib\net461\Mediachase.MetaDataPlus.dll True - ..\..\packages\EPiServer.Commerce.Core.13.9.0\lib\net461\Mediachase.Search.dll + ..\..\packages\EPiServer.Commerce.Core.13.10.0\lib\net461\Mediachase.Search.dll True - ..\..\packages\EPiServer.Commerce.Core.13.9.0\lib\net461\Mediachase.Search.Extensions.dll + ..\..\packages\EPiServer.Commerce.Core.13.10.0\lib\net461\Mediachase.Search.Extensions.dll True - ..\..\packages\EPiServer.Commerce.Core.13.9.0\lib\net461\Mediachase.Search.LuceneSearchProvider.dll + ..\..\packages\EPiServer.Commerce.Core.13.10.0\lib\net461\Mediachase.Search.LuceneSearchProvider.dll True - ..\..\packages\EPiServer.Commerce.Core.13.9.0\lib\net461\Mediachase.SqlDataProvider.dll + ..\..\packages\EPiServer.Commerce.Core.13.10.0\lib\net461\Mediachase.SqlDataProvider.dll True - ..\..\packages\EPiServer.Commerce.Core.13.9.0\lib\net461\Mediachase.WebConsoleLib.dll + ..\..\packages\EPiServer.Commerce.Core.13.10.0\lib\net461\Mediachase.WebConsoleLib.dll True - ..\..\packages\EPiServer.Commerce.Core.13.9.0\lib\net461\AjaxControlToolkit.dll + ..\..\packages\EPiServer.Commerce.Core.13.10.0\lib\net461\AjaxControlToolkit.dll True diff --git a/Sources/EPiServer.Reference.Commerce.Shared/packages.config b/Sources/EPiServer.Reference.Commerce.Shared/packages.config index 09ef1b56..2f0cb381 100644 --- a/Sources/EPiServer.Reference.Commerce.Shared/packages.config +++ b/Sources/EPiServer.Reference.Commerce.Shared/packages.config @@ -39,5 +39,5 @@ - + diff --git a/Sources/EPiServer.Reference.Commerce.Site.Tests/EPiServer.Reference.Commerce.Site.Tests.csproj b/Sources/EPiServer.Reference.Commerce.Site.Tests/EPiServer.Reference.Commerce.Site.Tests.csproj index 22b2651d..100c18e8 100644 --- a/Sources/EPiServer.Reference.Commerce.Site.Tests/EPiServer.Reference.Commerce.Site.Tests.csproj +++ b/Sources/EPiServer.Reference.Commerce.Site.Tests/EPiServer.Reference.Commerce.Site.Tests.csproj @@ -303,7 +303,6 @@ - @@ -398,91 +397,91 @@ --> - ..\..\packages\EPiServer.Commerce.Core.13.9.0\lib\net461\EPiServer.Business.Commerce.dll + ..\..\packages\EPiServer.Commerce.Core.13.10.0\lib\net461\EPiServer.Business.Commerce.dll True - ..\..\packages\EPiServer.Commerce.Core.13.9.0\lib\net461\EPiServer.Commerce.Reporting.dll + ..\..\packages\EPiServer.Commerce.Core.13.10.0\lib\net461\EPiServer.Commerce.Reporting.dll True - ..\..\packages\EPiServer.Commerce.Core.13.9.0\lib\net461\EPiServer.Commerce.Internal.Migration.dll + ..\..\packages\EPiServer.Commerce.Core.13.10.0\lib\net461\EPiServer.Commerce.Internal.Migration.dll True - ..\..\packages\EPiServer.Commerce.Core.13.9.0\lib\net461\Mediachase.BusinessFoundation.dll + ..\..\packages\EPiServer.Commerce.Core.13.10.0\lib\net461\Mediachase.BusinessFoundation.dll True - ..\..\packages\EPiServer.Commerce.Core.13.9.0\lib\net461\Mediachase.BusinessFoundation.Data.dll + ..\..\packages\EPiServer.Commerce.Core.13.10.0\lib\net461\Mediachase.BusinessFoundation.Data.dll True - ..\..\packages\EPiServer.Commerce.Core.13.9.0\lib\net461\Mediachase.Commerce.dll + ..\..\packages\EPiServer.Commerce.Core.13.10.0\lib\net461\Mediachase.Commerce.dll True - ..\..\packages\EPiServer.Commerce.Core.13.9.0\lib\net461\Mediachase.Commerce.Marketing.Validators.dll + ..\..\packages\EPiServer.Commerce.Core.13.10.0\lib\net461\Mediachase.Commerce.Marketing.Validators.dll True - ..\..\packages\EPiServer.Commerce.Core.13.9.0\lib\net461\Mediachase.Commerce.Plugins.Payment.dll + ..\..\packages\EPiServer.Commerce.Core.13.10.0\lib\net461\Mediachase.Commerce.Plugins.Payment.dll True - ..\..\packages\EPiServer.Commerce.Core.13.9.0\lib\net461\Mediachase.Commerce.Plugins.Shipping.dll + ..\..\packages\EPiServer.Commerce.Core.13.10.0\lib\net461\Mediachase.Commerce.Plugins.Shipping.dll True - ..\..\packages\EPiServer.Commerce.Core.13.9.0\lib\net461\Mediachase.Commerce.Website.dll + ..\..\packages\EPiServer.Commerce.Core.13.10.0\lib\net461\Mediachase.Commerce.Website.dll True - ..\..\packages\EPiServer.Commerce.Core.13.9.0\lib\net461\Mediachase.Commerce.Workflow.dll + ..\..\packages\EPiServer.Commerce.Core.13.10.0\lib\net461\Mediachase.Commerce.Workflow.dll True - ..\..\packages\EPiServer.Commerce.Core.13.9.0\lib\net461\Mediachase.DataProvider.dll + ..\..\packages\EPiServer.Commerce.Core.13.10.0\lib\net461\Mediachase.DataProvider.dll True - ..\..\packages\EPiServer.Commerce.Core.13.9.0\lib\net461\Mediachase.FileUploader.dll + ..\..\packages\EPiServer.Commerce.Core.13.10.0\lib\net461\Mediachase.FileUploader.dll True - ..\..\packages\EPiServer.Commerce.Core.13.9.0\lib\net461\Mediachase.MetaDataPlus.dll + ..\..\packages\EPiServer.Commerce.Core.13.10.0\lib\net461\Mediachase.MetaDataPlus.dll True - ..\..\packages\EPiServer.Commerce.Core.13.9.0\lib\net461\Mediachase.Search.dll + ..\..\packages\EPiServer.Commerce.Core.13.10.0\lib\net461\Mediachase.Search.dll True - ..\..\packages\EPiServer.Commerce.Core.13.9.0\lib\net461\Mediachase.Search.Extensions.dll + ..\..\packages\EPiServer.Commerce.Core.13.10.0\lib\net461\Mediachase.Search.Extensions.dll True - ..\..\packages\EPiServer.Commerce.Core.13.9.0\lib\net461\Mediachase.Search.LuceneSearchProvider.dll + ..\..\packages\EPiServer.Commerce.Core.13.10.0\lib\net461\Mediachase.Search.LuceneSearchProvider.dll True - ..\..\packages\EPiServer.Commerce.Core.13.9.0\lib\net461\Mediachase.SqlDataProvider.dll + ..\..\packages\EPiServer.Commerce.Core.13.10.0\lib\net461\Mediachase.SqlDataProvider.dll True - ..\..\packages\EPiServer.Commerce.Core.13.9.0\lib\net461\Mediachase.WebConsoleLib.dll + ..\..\packages\EPiServer.Commerce.Core.13.10.0\lib\net461\Mediachase.WebConsoleLib.dll True - ..\..\packages\EPiServer.Tracking.Commerce.3.2.1\lib\net461\EPiServer.Tracking.Commerce.dll + ..\..\packages\EPiServer.Tracking.Commerce.3.2.2\lib\net461\EPiServer.Tracking.Commerce.dll True - ..\..\packages\EPiServer.Personalization.Commerce.3.2.1\lib\net461\EPiServer.Personalization.Commerce.dll + ..\..\packages\EPiServer.Personalization.Commerce.3.2.2\lib\net461\EPiServer.Personalization.Commerce.dll True - ..\..\packages\EPiServer.Commerce.Core.13.9.0\lib\net461\AjaxControlToolkit.dll + ..\..\packages\EPiServer.Commerce.Core.13.10.0\lib\net461\AjaxControlToolkit.dll True diff --git a/Sources/EPiServer.Reference.Commerce.Site.Tests/Features/Checkout/Services/CheckoutAddressHandlingTests.cs b/Sources/EPiServer.Reference.Commerce.Site.Tests/Features/Checkout/Services/CheckoutAddressHandlingTests.cs index 63e9bab5..fd76f285 100644 --- a/Sources/EPiServer.Reference.Commerce.Site.Tests/Features/Checkout/Services/CheckoutAddressHandlingTests.cs +++ b/Sources/EPiServer.Reference.Commerce.Site.Tests/Features/Checkout/Services/CheckoutAddressHandlingTests.cs @@ -1,5 +1,6 @@ using System.Collections.Generic; using System.Linq; +using EPiServer.Data; using EPiServer.Reference.Commerce.Site.Features.AddressBook.Services; using EPiServer.Reference.Commerce.Site.Features.Cart.ViewModels; using EPiServer.Reference.Commerce.Site.Features.Checkout.Services; @@ -158,11 +159,13 @@ public void ChangeAddress_WhenShippingAddressIndexHasInValidValue_ShouldUpdateBi private readonly CheckoutAddressHandling _subject; private readonly Mock _addressBookServiceMock; + private readonly Mock _databaseModeMock; public CheckoutAddressHandlingTests() { _addressBookServiceMock = new Mock(); - _subject = new CheckoutAddressHandling(_addressBookServiceMock.Object); + _databaseModeMock = new Mock(); + _subject = new CheckoutAddressHandling(_addressBookServiceMock.Object, _databaseModeMock.Object); } } } diff --git a/Sources/EPiServer.Reference.Commerce.Site.Tests/Features/Checkout/Services/CheckoutServiceTests.cs b/Sources/EPiServer.Reference.Commerce.Site.Tests/Features/Checkout/Services/CheckoutServiceTests.cs index 99f6295f..65218227 100644 --- a/Sources/EPiServer.Reference.Commerce.Site.Tests/Features/Checkout/Services/CheckoutServiceTests.cs +++ b/Sources/EPiServer.Reference.Commerce.Site.Tests/Features/Checkout/Services/CheckoutServiceTests.cs @@ -1,5 +1,6 @@ using EPiServer.Commerce.Order; using EPiServer.Core; +using EPiServer.Data; using EPiServer.Framework.Localization; using EPiServer.Reference.Commerce.Shared.Services; using EPiServer.Reference.Commerce.Site.Features.AddressBook.Services; @@ -259,12 +260,12 @@ public void PlaceOrder_WhenPaymentProcessingFails_ShouldReturnNullAndAddModelErr _orderGroupCalculatorMock.Setup(p => p.GetTotal(It.IsAny())).Throws(new PaymentException("", "", "")); - var PaymentMethodMock = new Mock(String.Empty); + var paymentMethodMock = new Mock(string.Empty); var viewModel = new CheckoutViewModel { BillingAddress = new AddressModel { AddressId = "billingAddress" }, - Payment = PaymentMethodMock.Object + Payment = paymentMethodMock.Object }; var result = _subject.PlaceOrder(cart, modelState, viewModel); @@ -380,6 +381,8 @@ public void SendConfirmation_WhenFails_ShouldReturnFalse() private readonly Mock _customerContextFacadeMock; private readonly Mock _paymentProcessorMock; private readonly Mock _localizedOrderValidationServiceMock; + private readonly Mock _databaseModeMock; + public CheckoutServiceTests() { var addressBookServiceMock = new Mock(); @@ -388,6 +391,7 @@ public CheckoutServiceTests() _orderGroupCalculatorMock = new Mock(); _orderRepositoryMock = new Mock(); + _databaseModeMock = new Mock(); _mailServiceMock = new Mock(); _contentRepositoryMock = new Mock(); @@ -414,7 +418,8 @@ public CheckoutServiceTests() _customerContextFacadeMock.Object, new MemoryLocalizationService(), _mailServiceMock.Object, - _cartServiceMock.Object); + _cartServiceMock.Object, + _databaseModeMock.Object); } } } diff --git a/Sources/EPiServer.Reference.Commerce.Site.Tests/Features/ErrorHandling/Controllers/ErrorHandlingControllerTests.cs b/Sources/EPiServer.Reference.Commerce.Site.Tests/Features/ErrorHandling/Controllers/ErrorHandlingControllerTests.cs deleted file mode 100644 index 89519102..00000000 --- a/Sources/EPiServer.Reference.Commerce.Site.Tests/Features/ErrorHandling/Controllers/ErrorHandlingControllerTests.cs +++ /dev/null @@ -1,85 +0,0 @@ -using EPiServer.Core; -using EPiServer.Reference.Commerce.Site.Features.ErrorHandling.Controllers; -using EPiServer.Reference.Commerce.Site.Features.ErrorHandling.Pages; -using EPiServer.Reference.Commerce.Site.Features.Start.Pages; -using EPiServer.Web.Routing; -using Moq; -using System; -using System.Web.Mvc; -using EPiServer.Reference.Commerce.Site.Features.ErrorHandling.ViewModels; -using Xunit; - -namespace EPiServer.Reference.Commerce.Site.Tests.Features.ErrorHandling.Controllers -{ - - public class ErrorHandlingControllerTests - { - [Fact] - public void Index_WhenPassingPage_ShouldUseItOnModel() - { - // Arrange - var errorPage = new ErrorPage(); - - // Act - var result = (ViewResult)_subject.Index(errorPage); - - // Assert - Assert.Equal(errorPage, ((ErrorViewModel)result.Model).CurrentPage); - } - - [Fact] - public void PageNotFound_WhenUrlCanBeResolved_ShouldRedirectToUrl() - { - // Arrange - var resolvedUrl = "http://example.com/Resolved/"; - _urlResolver.Setup(u => u.GetUrl(It.IsAny())).Returns(resolvedUrl); - - // Act - var result = (RedirectResult)_subject.PageNotFound(); - - // Assert - Assert.Equal(resolvedUrl, result.Url); - } - - [Fact] - public void PageNotFound_WhenUrlResolvingThrows_ShouldRedirectToFallback() - { - // Arrange - _urlResolver.Setup(u => u.GetUrl(It.IsAny())).Throws(new EPiServerException("Oops")); - - // Act - var result = (RedirectResult)_subject.PageNotFound(); - - // Assert - Assert.Equal(_fallbackUrl, result.Url); - } - - [Fact] - public void PageNotFound_WhenUrlResolvingReturnsNull_ShouldRedirectToFallback() - { - // Arrange - _urlResolver.Setup(u => u.GetUrl(It.IsAny())).Returns((String)null); - - // Act - var result = (RedirectResult)_subject.PageNotFound(); - - // Assert - Assert.Equal(_fallbackUrl, result.Url); - } - - ErrorHandlingController _subject; - Mock _contentLoaderMock; - Mock _urlResolver; - string _fallbackUrl = "~/Features/ErrorHandling/Pages/ErrorFallback.html"; - - - public ErrorHandlingControllerTests() - { - _contentLoaderMock = new Mock(); - _contentLoaderMock.Setup(c => c.Get(It.IsAny())).Returns(new StartPage()); - _urlResolver = new Mock(); - - _subject = new ErrorHandlingController(_contentLoaderMock.Object, _urlResolver.Object); - } - } -} diff --git a/Sources/EPiServer.Reference.Commerce.Site.Tests/app.config b/Sources/EPiServer.Reference.Commerce.Site.Tests/app.config index 63830d0c..3f49079c 100644 --- a/Sources/EPiServer.Reference.Commerce.Site.Tests/app.config +++ b/Sources/EPiServer.Reference.Commerce.Site.Tests/app.config @@ -118,6 +118,10 @@ + + + + diff --git a/Sources/EPiServer.Reference.Commerce.Site.Tests/packages.config b/Sources/EPiServer.Reference.Commerce.Site.Tests/packages.config index 5c60032f..c3262e8d 100644 --- a/Sources/EPiServer.Reference.Commerce.Site.Tests/packages.config +++ b/Sources/EPiServer.Reference.Commerce.Site.Tests/packages.config @@ -55,7 +55,7 @@ - - - + + + diff --git a/Sources/EPiServer.Reference.Commerce.Site/App_Data/DefaultSiteContent.episerverdata b/Sources/EPiServer.Reference.Commerce.Site/App_Data/DefaultSiteContent.episerverdata index 8e1f48bf..5bb1498e 100644 Binary files a/Sources/EPiServer.Reference.Commerce.Site/App_Data/DefaultSiteContent.episerverdata and b/Sources/EPiServer.Reference.Commerce.Site/App_Data/DefaultSiteContent.episerverdata differ diff --git a/Sources/EPiServer.Reference.Commerce.Site/EPiServer.Reference.Commerce.Site.csproj b/Sources/EPiServer.Reference.Commerce.Site/EPiServer.Reference.Commerce.Site.csproj index 271cb63f..e04164b4 100644 --- a/Sources/EPiServer.Reference.Commerce.Site/EPiServer.Reference.Commerce.Site.csproj +++ b/Sources/EPiServer.Reference.Commerce.Site/EPiServer.Reference.Commerce.Site.csproj @@ -133,6 +133,9 @@ ..\..\packages\EPiServer.CMS.UI.Core.11.21.4\lib\net461\EPiServer.UI.dll + + ..\..\packages\EPiServer.Turnstile.Contracts.Hmac.3.3.1\lib\net461\EPiServer.Turnstile.Contracts.Hmac.dll + ..\..\packages\EPiServer.CMS.AspNet.11.13.0\lib\net461\EPiServer.Web.WebControls.dll @@ -239,7 +242,9 @@ - + + ..\..\packages\System.Net.Http.4.3.3\lib\net46\System.Net.Http.dll + ..\..\packages\Microsoft.AspNet.WebApi.Client.5.2.3\lib\net45\System.Net.Http.Formatting.dll @@ -432,8 +437,6 @@ - - @@ -626,8 +629,7 @@ - - + @@ -808,6 +810,9 @@ + + + web.config @@ -1013,107 +1018,107 @@ - ..\..\packages\EPiServer.Commerce.Core.13.9.0\lib\net461\EPiServer.Business.Commerce.dll + ..\..\packages\EPiServer.Commerce.Core.13.10.0\lib\net461\EPiServer.Business.Commerce.dll True - ..\..\packages\EPiServer.Commerce.Core.13.9.0\lib\net461\EPiServer.Commerce.Internal.Migration.dll + ..\..\packages\EPiServer.Commerce.Core.13.10.0\lib\net461\EPiServer.Commerce.Internal.Migration.dll True - ..\..\packages\EPiServer.Commerce.Core.13.9.0\lib\net461\Mediachase.BusinessFoundation.dll + ..\..\packages\EPiServer.Commerce.Core.13.10.0\lib\net461\Mediachase.BusinessFoundation.dll True - ..\..\packages\EPiServer.Commerce.Core.13.9.0\lib\net461\Mediachase.BusinessFoundation.Data.dll + ..\..\packages\EPiServer.Commerce.Core.13.10.0\lib\net461\Mediachase.BusinessFoundation.Data.dll True - ..\..\packages\EPiServer.Commerce.Core.13.9.0\lib\net461\Mediachase.Commerce.dll + ..\..\packages\EPiServer.Commerce.Core.13.10.0\lib\net461\Mediachase.Commerce.dll True - ..\..\packages\EPiServer.Commerce.Core.13.9.0\lib\net461\Mediachase.Commerce.Marketing.Validators.dll + ..\..\packages\EPiServer.Commerce.Core.13.10.0\lib\net461\Mediachase.Commerce.Marketing.Validators.dll True - ..\..\packages\EPiServer.Commerce.Core.13.9.0\lib\net461\Mediachase.Commerce.Plugins.Payment.dll + ..\..\packages\EPiServer.Commerce.Core.13.10.0\lib\net461\Mediachase.Commerce.Plugins.Payment.dll True - ..\..\packages\EPiServer.Commerce.Core.13.9.0\lib\net461\Mediachase.Commerce.Plugins.Shipping.dll + ..\..\packages\EPiServer.Commerce.Core.13.10.0\lib\net461\Mediachase.Commerce.Plugins.Shipping.dll True - ..\..\packages\EPiServer.Commerce.Core.13.9.0\lib\net461\Mediachase.Commerce.Website.dll + ..\..\packages\EPiServer.Commerce.Core.13.10.0\lib\net461\Mediachase.Commerce.Website.dll True - ..\..\packages\EPiServer.Commerce.Core.13.9.0\lib\net461\Mediachase.Commerce.Workflow.dll + ..\..\packages\EPiServer.Commerce.Core.13.10.0\lib\net461\Mediachase.Commerce.Workflow.dll True - ..\..\packages\EPiServer.Commerce.Core.13.9.0\lib\net461\Mediachase.DataProvider.dll + ..\..\packages\EPiServer.Commerce.Core.13.10.0\lib\net461\Mediachase.DataProvider.dll True - ..\..\packages\EPiServer.Commerce.Core.13.9.0\lib\net461\Mediachase.FileUploader.dll + ..\..\packages\EPiServer.Commerce.Core.13.10.0\lib\net461\Mediachase.FileUploader.dll True - ..\..\packages\EPiServer.Commerce.Core.13.9.0\lib\net461\Mediachase.MetaDataPlus.dll + ..\..\packages\EPiServer.Commerce.Core.13.10.0\lib\net461\Mediachase.MetaDataPlus.dll True - ..\..\packages\EPiServer.Commerce.Core.13.9.0\lib\net461\Mediachase.Search.dll + ..\..\packages\EPiServer.Commerce.Core.13.10.0\lib\net461\Mediachase.Search.dll True - ..\..\packages\EPiServer.Commerce.Core.13.9.0\lib\net461\Mediachase.Search.Extensions.dll + ..\..\packages\EPiServer.Commerce.Core.13.10.0\lib\net461\Mediachase.Search.Extensions.dll True - ..\..\packages\EPiServer.Commerce.Core.13.9.0\lib\net461\Mediachase.Search.LuceneSearchProvider.dll + ..\..\packages\EPiServer.Commerce.Core.13.10.0\lib\net461\Mediachase.Search.LuceneSearchProvider.dll True - ..\..\packages\EPiServer.Commerce.Core.13.9.0\lib\net461\Mediachase.SqlDataProvider.dll + ..\..\packages\EPiServer.Commerce.Core.13.10.0\lib\net461\Mediachase.SqlDataProvider.dll True - ..\..\packages\EPiServer.Commerce.Core.13.9.0\lib\net461\Mediachase.WebConsoleLib.dll + ..\..\packages\EPiServer.Commerce.Core.13.10.0\lib\net461\Mediachase.WebConsoleLib.dll True - ..\..\packages\EPiServer.Commerce.UI.13.9.0\lib\net461\EPiServer.Commerce.Shell.dll + ..\..\packages\EPiServer.Commerce.UI.13.10.0\lib\net461\EPiServer.Commerce.Shell.dll True - ..\..\packages\EPiServer.Commerce.UI.ManagerIntegration.13.9.0\lib\net461\EPiServer.Commerce.Shell.ManagerIntegration.dll + ..\..\packages\EPiServer.Commerce.UI.ManagerIntegration.13.10.0\lib\net461\EPiServer.Commerce.Shell.ManagerIntegration.dll True - ..\..\packages\EPiServer.Commerce.UI.13.9.0\lib\net461\EPiServer.Commerce.UI.dll + ..\..\packages\EPiServer.Commerce.UI.13.10.0\lib\net461\EPiServer.Commerce.UI.dll True - ..\..\packages\EPiServer.Commerce.UI.CustomerService.13.9.0\lib\net461\EPiServer.Commerce.UI.CustomerService.dll + ..\..\packages\EPiServer.Commerce.UI.CustomerService.13.10.0\lib\net461\EPiServer.Commerce.UI.CustomerService.dll True - ..\..\packages\EPiServer.Commerce.Core.13.9.0\lib\net461\EPiServer.Commerce.Reporting.dll + ..\..\packages\EPiServer.Commerce.Core.13.10.0\lib\net461\EPiServer.Commerce.Reporting.dll True - ..\..\packages\EPiServer.Tracking.Commerce.3.2.1\lib\net461\EPiServer.Tracking.Commerce.dll + ..\..\packages\EPiServer.Tracking.Commerce.3.2.2\lib\net461\EPiServer.Tracking.Commerce.dll True - ..\..\packages\EPiServer.Personalization.Commerce.3.2.1\lib\net461\EPiServer.Personalization.Commerce.dll + ..\..\packages\EPiServer.Personalization.Commerce.3.2.2\lib\net461\EPiServer.Personalization.Commerce.dll True - ..\..\packages\EPiServer.Commerce.Core.13.9.0\lib\net461\AjaxControlToolkit.dll + ..\..\packages\EPiServer.Commerce.Core.13.10.0\lib\net461\AjaxControlToolkit.dll True diff --git a/Sources/EPiServer.Reference.Commerce.Site/Features/Cart/Controllers/CartController.cs b/Sources/EPiServer.Reference.Commerce.Site/Features/Cart/Controllers/CartController.cs index 14c5cfef..ae2884c5 100644 --- a/Sources/EPiServer.Reference.Commerce.Site/Features/Cart/Controllers/CartController.cs +++ b/Sources/EPiServer.Reference.Commerce.Site/Features/Cart/Controllers/CartController.cs @@ -48,7 +48,6 @@ public ActionResult LargeCart() } [HttpPost] - [AllowDBWrite] public async Task AddToCart(string code) { ModelState.Clear(); @@ -71,7 +70,6 @@ public async Task AddToCart(string code) } [HttpPost] - [AllowDBWrite] public async Task ChangeCartItem(int shipmentId, string code, decimal quantity, string size, string newSize, string displayName) { ModelState.Clear(); @@ -90,7 +88,6 @@ public async Task ChangeCartItem(int shipmentId, string code, deci } [HttpPost] - [AllowDBWrite] public ActionResult UpdateShippingMethod(UpdateShippingMethodViewModel viewModel) { ModelState.Clear(); diff --git a/Sources/EPiServer.Reference.Commerce.Site/Features/Checkout/Controllers/CheckoutController.cs b/Sources/EPiServer.Reference.Commerce.Site/Features/Checkout/Controllers/CheckoutController.cs index 497c87ea..b7640aa8 100644 --- a/Sources/EPiServer.Reference.Commerce.Site/Features/Checkout/Controllers/CheckoutController.cs +++ b/Sources/EPiServer.Reference.Commerce.Site/Features/Checkout/Controllers/CheckoutController.cs @@ -1,5 +1,6 @@ using EPiServer.Commerce.Order; using EPiServer.Core; +using EPiServer.Data; using EPiServer.Reference.Commerce.Site.Features.Cart.Services; using EPiServer.Reference.Commerce.Site.Features.Checkout.Pages; using EPiServer.Reference.Commerce.Site.Features.Checkout.Services; @@ -7,11 +8,13 @@ using EPiServer.Reference.Commerce.Site.Features.Checkout.ViewModels; using EPiServer.Reference.Commerce.Site.Features.Market.Services; using EPiServer.Reference.Commerce.Site.Features.Recommendations.Services; +using EPiServer.Reference.Commerce.Site.Features.Shared.Models; using EPiServer.Reference.Commerce.Site.Features.Shared.Services; using EPiServer.Reference.Commerce.Site.Infrastructure.Attributes; using EPiServer.Web.Mvc; using EPiServer.Web.Mvc.Html; using EPiServer.Web.Routing; +using System; using System.Linq; using System.Threading.Tasks; using System.Web.Mvc; @@ -30,6 +33,7 @@ public class CheckoutController : PageController private readonly OrderValidationService _orderValidationService; private ICart _cart; private readonly CheckoutService _checkoutService; + private readonly IDatabaseMode _databaseMode; public CheckoutController( ICurrencyService currencyService, @@ -39,8 +43,9 @@ public CheckoutController( ICartService cartService, OrderSummaryViewModelFactory orderSummaryViewModelFactory, IRecommendationService recommendationService, - CheckoutService checkoutService, - OrderValidationService orderValidationService) + CheckoutService checkoutService, + OrderValidationService orderValidationService, + IDatabaseMode databaseMode) { _currencyService = currencyService; _controllerExceptionHandler = controllerExceptionHandler; @@ -51,6 +56,7 @@ public CheckoutController( _recommendationService = recommendationService; _checkoutService = checkoutService; _orderValidationService = orderValidationService; + _databaseMode = databaseMode; } [HttpGet] @@ -92,11 +98,23 @@ public ActionResult SingleShipment(CheckoutPage currentPage) } [HttpPost] - [AllowDBWrite] public ActionResult ChangeAddress(UpdateAddressViewModel addressViewModel) { ModelState.Clear(); + var viewModel = CreateCheckoutViewModel(addressViewModel.CurrentPage); + + // Set random value for Name/Id if null. + if (addressViewModel.BillingAddress.AddressId == null) + { + addressViewModel.BillingAddress.Name = addressViewModel.BillingAddress.AddressId = Guid.NewGuid().ToString(); + } + + foreach (var shipment in addressViewModel.Shipments.Where(x => x.Address.AddressId == null)) + { + shipment.Address.Name = shipment.Address.AddressId = Guid.NewGuid().ToString(); + } + _checkoutService.CheckoutAddressHandling.ChangeAddress(viewModel, addressViewModel); _checkoutService.UpdateShippingAddresses(Cart, viewModel); @@ -136,9 +154,8 @@ public ActionResult RemoveCouponCode(CheckoutPage currentPage, string couponCode var viewModel = CreateCheckoutViewModel(currentPage); return View(viewModel.ViewName, viewModel); } - + [HttpPost] - [AllowDBWrite] public ActionResult Purchase(CheckoutViewModel viewModel, IPaymentMethod paymentMethod) { if (CartIsNullOrEmpty()) @@ -150,20 +167,22 @@ public ActionResult Purchase(CheckoutViewModel viewModel, IPaymentMethod payment viewModel.IsAuthenticated = User.Identity.IsAuthenticated; + + _checkoutService.CheckoutAddressHandling.UpdateUserAddresses(viewModel); if (!_checkoutService.ValidateOrder(ModelState, viewModel, _orderValidationService.ValidateOrder(Cart))) { return View(viewModel); } - + if (!paymentMethod.ValidateData()) { return View(viewModel); } _checkoutService.UpdateShippingAddresses(Cart, viewModel); - + _checkoutService.CreateAndAddPaymentToCart(Cart, viewModel); var purchaseOrder = _checkoutService.PlaceOrder(Cart, ModelState, viewModel); @@ -176,7 +195,7 @@ public ActionResult Purchase(CheckoutViewModel viewModel, IPaymentMethod payment { return View(viewModel); } - + var confirmationSentSuccessfully = _checkoutService.SendConfirmation(viewModel, purchaseOrder); return Redirect(_checkoutService.BuildRedirectionUrl(viewModel, purchaseOrder, confirmationSentSuccessfully)); @@ -208,7 +227,8 @@ private ViewResult View(CheckoutViewModel checkoutViewModel) private CheckoutViewModel CreateCheckoutViewModel(CheckoutPage currentPage, IPaymentMethod paymentMethod = null) { - return _checkoutViewModelFactory.CreateCheckoutViewModel(Cart, currentPage, paymentMethod); + var checkoutViewModel = _checkoutViewModelFactory.CreateCheckoutViewModel(Cart, currentPage, paymentMethod); + return checkoutViewModel; } private ICart Cart => _cart ?? (_cart = _cartService.LoadCart(_cartService.DefaultCartName)); diff --git a/Sources/EPiServer.Reference.Commerce.Site/Features/Checkout/Services/CheckoutAddressHandling.cs b/Sources/EPiServer.Reference.Commerce.Site/Features/Checkout/Services/CheckoutAddressHandling.cs index 01a852a5..1a037764 100644 --- a/Sources/EPiServer.Reference.Commerce.Site/Features/Checkout/Services/CheckoutAddressHandling.cs +++ b/Sources/EPiServer.Reference.Commerce.Site/Features/Checkout/Services/CheckoutAddressHandling.cs @@ -1,5 +1,6 @@ using System; using System.Linq; +using EPiServer.Data; using EPiServer.Reference.Commerce.Site.Features.AddressBook.Services; using EPiServer.Reference.Commerce.Site.Features.Checkout.ViewModels; @@ -8,10 +9,12 @@ namespace EPiServer.Reference.Commerce.Site.Features.Checkout.Services public class CheckoutAddressHandling { private readonly IAddressBookService _addressBookService; + private readonly IDatabaseMode _databaseMode; - public CheckoutAddressHandling(IAddressBookService addressBookService) + public CheckoutAddressHandling(IAddressBookService addressBookService, IDatabaseMode databaseMode) { _addressBookService = addressBookService; + _databaseMode = databaseMode; } public virtual void UpdateUserAddresses(CheckoutViewModel viewModel) @@ -30,8 +33,8 @@ public virtual void ChangeAddress(CheckoutViewModel viewModel, UpdateAddressView { var isShippingAddressUpdated = updateViewModel.ShippingAddressIndex > -1; - var updatedAddress = isShippingAddressUpdated ? - updateViewModel.Shipments[updateViewModel.ShippingAddressIndex].Address : + var updatedAddress = isShippingAddressUpdated ? + updateViewModel.Shipments[updateViewModel.ShippingAddressIndex].Address : updateViewModel.BillingAddress; if (updatedAddress.AddressId != null) @@ -60,21 +63,41 @@ public virtual void ChangeAddress(CheckoutViewModel viewModel, UpdateAddressView private void SetDefaultBillingAddressName(CheckoutViewModel viewModel) { - Guid guid; - if (Guid.TryParse(viewModel.BillingAddress.Name, out guid)) + if (IsInReadOnlyMode()) { - viewModel.BillingAddress.Name = "Billing address (" + viewModel.BillingAddress.Line1 + ")"; + if (viewModel.BillingAddress.AddressId == null) + { + viewModel.BillingAddress.Name = viewModel.BillingAddress.AddressId = Guid.NewGuid().ToString(); + } + } + else + { + Guid guid; + if (Guid.TryParse(viewModel.BillingAddress.Name, out guid)) + { + viewModel.BillingAddress.Name = "Billing address (" + viewModel.BillingAddress.Line1 + ")"; + } } } private void SetDefaultShippingAddressesNames(CheckoutViewModel viewModel) { - foreach (var address in viewModel.Shipments.Select(x => x.Address)) + if (IsInReadOnlyMode()) { - Guid guid; - if (Guid.TryParse(address.Name, out guid)) + foreach (var shipment in viewModel.Shipments.Where(x => x.Address.AddressId == null)) + { + shipment.Address.Name = shipment.Address.AddressId = Guid.NewGuid().ToString(); + } + } + else + { + foreach (var address in viewModel.Shipments.Select(x => x.Address)) { - address.Name = "Shipping address (" + address.Line1 + ")"; + Guid guid; + if (Guid.TryParse(address.Name, out guid)) + { + address.Name = "Shipping address (" + address.Line1 + ")"; + } } } } @@ -96,6 +119,20 @@ private void UpdateAuthenticatedUserAddresses(CheckoutViewModel viewModel) { LoadBillingAddressFromAddressBook(viewModel); LoadShippingAddressesFromAddressBook(viewModel); + + if (IsInReadOnlyMode()) + { + if (viewModel.BillingAddress.AddressId == null) + { + viewModel.BillingAddress.AddressId = Guid.NewGuid().ToString(); + } + + foreach (var shipment in viewModel.Shipments.Where(x => x.Address.AddressId == null)) + { + shipment.Address.Name = shipment.Address.AddressId = Guid.NewGuid().ToString(); + } + } + if (viewModel.UseBillingAddressForShipment) { viewModel.Shipments.Single().Address = viewModel.BillingAddress; @@ -112,5 +149,7 @@ private void UpdateAnonymousUserAddresses(CheckoutViewModel viewModel) viewModel.Shipments.Single().Address = viewModel.BillingAddress; } } + + private bool IsInReadOnlyMode() => _databaseMode.DatabaseMode == DatabaseMode.ReadOnly; } } \ No newline at end of file diff --git a/Sources/EPiServer.Reference.Commerce.Site/Features/Checkout/Services/CheckoutService.cs b/Sources/EPiServer.Reference.Commerce.Site/Features/Checkout/Services/CheckoutService.cs index 040df21f..b456ee85 100644 --- a/Sources/EPiServer.Reference.Commerce.Site/Features/Checkout/Services/CheckoutService.cs +++ b/Sources/EPiServer.Reference.Commerce.Site/Features/Checkout/Services/CheckoutService.cs @@ -1,6 +1,6 @@ -using EPiServer.Commerce.Marketing; -using EPiServer.Commerce.Order; +using EPiServer.Commerce.Order; using EPiServer.Core; +using EPiServer.Data; using EPiServer.Framework.Localization; using EPiServer.Logging; using EPiServer.Reference.Commerce.Shared.Services; @@ -35,6 +35,7 @@ public class CheckoutService private readonly IMailService _mailService; private readonly ILogger _log = LogManager.GetLogger(typeof(CheckoutService)); private readonly ICartService _cartService; + private readonly IDatabaseMode _databaseMode; public AuthenticatedPurchaseValidation AuthenticatedPurchaseValidation { get; } public AnonymousPurchaseValidation AnonymousPurchaseValidation { get; } @@ -50,7 +51,8 @@ public CheckoutService( CustomerContextFacade customerContext, LocalizationService localizationService, IMailService mailService, - ICartService cartService) + ICartService cartService, + IDatabaseMode databaseMode) { _addressBookService = addressBookService; _orderGroupFactory = orderGroupFactory; @@ -62,10 +64,11 @@ public CheckoutService( _localizationService = localizationService; _mailService = mailService; _cartService = cartService; + _databaseMode = databaseMode; AuthenticatedPurchaseValidation = new AuthenticatedPurchaseValidation(_localizationService); AnonymousPurchaseValidation = new AnonymousPurchaseValidation(_localizationService); - CheckoutAddressHandling = new CheckoutAddressHandling(_addressBookService); + CheckoutAddressHandling = new CheckoutAddressHandling(_addressBookService, databaseMode); } public virtual void UpdateShippingMethods(ICart cart, IList shipmentViewModels) @@ -139,19 +142,13 @@ public virtual IPurchaseOrder PlaceOrder(ICart cart, ModelStateDictionary modelS throw new InvalidOperationException("Wrong amount"); } - PurchaseValidation validation; - if (checkoutViewModel.IsAuthenticated) + if (!IsInReadOnlyMode()) { - validation = AuthenticatedPurchaseValidation; - } - else - { - validation = AnonymousPurchaseValidation; - } - - if (!validation.ValidateOrderOperation(modelState, _cartService.RequestInventory(cart))) - { - return null; + var validation = checkoutViewModel.IsAuthenticated ? AuthenticatedPurchaseValidation : (PurchaseValidation)AnonymousPurchaseValidation; + if (!validation.ValidateOrderOperation(modelState, _cartService.RequestInventory(cart))) + { + return null; + } } var orderReference = _orderRepository.SaveAsPurchaseOrder(cart); @@ -231,5 +228,7 @@ public void ProcessPaymentCancel(CheckoutViewModel viewModel, TempDataDictionary viewModel.Message = message; } } + + private bool IsInReadOnlyMode() => _databaseMode.DatabaseMode == DatabaseMode.ReadOnly; } } \ No newline at end of file diff --git a/Sources/EPiServer.Reference.Commerce.Site/Features/ErrorHandling/Controllers/ErrorHandlingController.cs b/Sources/EPiServer.Reference.Commerce.Site/Features/ErrorHandling/Controllers/ErrorHandlingController.cs index effa06a3..33992dbc 100644 --- a/Sources/EPiServer.Reference.Commerce.Site/Features/ErrorHandling/Controllers/ErrorHandlingController.cs +++ b/Sources/EPiServer.Reference.Commerce.Site/Features/ErrorHandling/Controllers/ErrorHandlingController.cs @@ -1,48 +1,55 @@ -using EPiServer.Core; -using EPiServer.Reference.Commerce.Site.Features.ErrorHandling.Pages; -using EPiServer.Reference.Commerce.Site.Features.ErrorHandling.ViewModels; -using EPiServer.Reference.Commerce.Site.Features.Start.Pages; -using EPiServer.Web.Mvc; -using EPiServer.Web.Routing; -using System; -using System.Web.Mvc; +using System.Web.Mvc; namespace EPiServer.Reference.Commerce.Site.Features.ErrorHandling.Controllers { - public class ErrorHandlingController : PageController - { - private readonly IContentLoader _contentLoader; - private readonly UrlResolver _urlResolver; + public class ErrorHandlingController : Controller + { + [HttpGet] + public ActionResult PageNotFound() + { + Response.TrySkipIisCustomErrors = true; + Response.StatusCode = 404; + return View(); + } - public ErrorHandlingController(IContentLoader contentLoader, UrlResolver urlResolver) + [HttpGet] + public ActionResult InternalError(string message = null) { - - _contentLoader = contentLoader; - _urlResolver = urlResolver; + Response.TrySkipIisCustomErrors = true; + Response.StatusCode = 500; + ViewBag.Message = message; + return View(); } [HttpGet] - public ActionResult Index(ErrorPage currentPage) + [PreventDirectAccess] + public ActionResult Forbidden(string message = null) { - var model = new ErrorViewModel - { - CurrentPage = currentPage - }; - return View(model); + Response.TrySkipIisCustomErrors = true; + Response.StatusCode = 403; + ViewBag.Message = message; + return View(); } [HttpGet] - public ActionResult PageNotFound() + [PreventDirectAccess] + public ActionResult OtherHttpStatusCode(int httpStatusCode) { - try - { - var startpage = _contentLoader.Get(ContentReference.StartPage); - var url = _urlResolver.GetUrl(startpage.PageNotFound); - return Redirect(url ?? "~/Features/ErrorHandling/Pages/ErrorFallback.html"); - } - catch (Exception) + Response.TrySkipIisCustomErrors = true; + Response.StatusCode = httpStatusCode; + ViewBag.StatusCode = httpStatusCode; + return View(httpStatusCode); + } + + private class PreventDirectAccessAttribute : FilterAttribute, IAuthorizationFilter + { + public void OnAuthorization(AuthorizationContext filterContext) { - return Redirect("~/Features/ErrorHandling/Pages/ErrorFallback.html"); + object value = filterContext.RouteData.Values["fromAppErrorEvent"]; + if (!(value is bool && (bool)value)) + { + filterContext.Result = new ViewResult { ViewName = "PageNotFound" }; + } } } } diff --git a/Sources/EPiServer.Reference.Commerce.Site/Features/ErrorHandling/Pages/ErrorFallback.html b/Sources/EPiServer.Reference.Commerce.Site/Features/ErrorHandling/Pages/ErrorFallback.html deleted file mode 100644 index 8806d4b1..00000000 --- a/Sources/EPiServer.Reference.Commerce.Site/Features/ErrorHandling/Pages/ErrorFallback.html +++ /dev/null @@ -1,7 +0,0 @@ - - -

Internal Error

- -
Something went wrong
- - diff --git a/Sources/EPiServer.Reference.Commerce.Site/Features/ErrorHandling/Pages/ErrorPage.cs b/Sources/EPiServer.Reference.Commerce.Site/Features/ErrorHandling/Pages/ErrorPage.cs deleted file mode 100644 index f4a413a3..00000000 --- a/Sources/EPiServer.Reference.Commerce.Site/Features/ErrorHandling/Pages/ErrorPage.cs +++ /dev/null @@ -1,16 +0,0 @@ -using EPiServer.DataAbstraction; -using EPiServer.DataAnnotations; -using EPiServer.Reference.Commerce.Site.Features.Shared.Pages; - -namespace EPiServer.Reference.Commerce.Site.Features.ErrorHandling.Pages -{ - [ContentType( - DisplayName = "Error page", - GUID = "E7DCAABC-05BC-4230-A2AF-94CD9A9ED535", - Description = "The page which allows you to show errors details.", - AvailableInEditMode = true)] - [ImageUrl("~/styles/images/page_type.png")] - public class ErrorPage : StandardPage - { - } -} \ No newline at end of file diff --git a/Sources/EPiServer.Reference.Commerce.Site/Features/ErrorHandling/ViewModels/ErrorViewModel.cs b/Sources/EPiServer.Reference.Commerce.Site/Features/ErrorHandling/ViewModels/ErrorViewModel.cs deleted file mode 100644 index d22866a4..00000000 --- a/Sources/EPiServer.Reference.Commerce.Site/Features/ErrorHandling/ViewModels/ErrorViewModel.cs +++ /dev/null @@ -1,9 +0,0 @@ -using EPiServer.Reference.Commerce.Site.Features.ErrorHandling.Pages; -using EPiServer.Reference.Commerce.Site.Features.Shared.ViewModels; - -namespace EPiServer.Reference.Commerce.Site.Features.ErrorHandling.ViewModels -{ - public class ErrorViewModel : PageViewModel - { - } -} \ No newline at end of file diff --git a/Sources/EPiServer.Reference.Commerce.Site/Features/Shared/Controllers/StandardPageController.cs b/Sources/EPiServer.Reference.Commerce.Site/Features/Shared/Controllers/StandardPageController.cs index 80bc0840..2efe3465 100644 --- a/Sources/EPiServer.Reference.Commerce.Site/Features/Shared/Controllers/StandardPageController.cs +++ b/Sources/EPiServer.Reference.Commerce.Site/Features/Shared/Controllers/StandardPageController.cs @@ -33,17 +33,14 @@ public ActionResult Index(StandardPage currentPage) [HttpGet] public ActionResult SuccessOptinConfirmation() - { - try - { - var startpage = _contentLoader.Get(ContentReference.StartPage); - var url = _urlResolver.GetUrl(startpage.OptinConfirmSuccessPage); - return Redirect(url ?? "~/Features/ErrorHandling/Pages/ErrorFallback.html"); - } - catch (Exception) + { + var startpage = _contentLoader.Get(ContentReference.StartPage); + var url = _urlResolver.GetUrl(startpage.OptinConfirmSuccessPage); + if (string.IsNullOrEmpty(url)) { - return Redirect("~/Features/ErrorHandling/Pages/ErrorFallback.html"); + throw new Exception(); } + return Redirect(url); } } } \ No newline at end of file diff --git a/Sources/EPiServer.Reference.Commerce.Site/Features/Start/Controllers/StartController.cs b/Sources/EPiServer.Reference.Commerce.Site/Features/Start/Controllers/StartController.cs index fe3fd988..7281232b 100644 --- a/Sources/EPiServer.Reference.Commerce.Site/Features/Start/Controllers/StartController.cs +++ b/Sources/EPiServer.Reference.Commerce.Site/Features/Start/Controllers/StartController.cs @@ -33,7 +33,7 @@ public ViewResult Index(StartPage currentPage) { StartPage = currentPage, Promotions = GetActivePromotions() - }; + }; return View(viewModel); } diff --git a/Sources/EPiServer.Reference.Commerce.Site/Features/Start/Pages/StartPage.cs b/Sources/EPiServer.Reference.Commerce.Site/Features/Start/Pages/StartPage.cs index 4848f296..91c67496 100644 --- a/Sources/EPiServer.Reference.Commerce.Site/Features/Start/Pages/StartPage.cs +++ b/Sources/EPiServer.Reference.Commerce.Site/Features/Start/Pages/StartPage.cs @@ -99,14 +99,7 @@ public class StartPage : PageData GroupName = SiteTabs.SiteStructure, Order = 6)] [AllowedTypes(typeof(ResetPasswordPage))] - public virtual ContentReference ResetPasswordPage { get; set; } - - [Display( - Name = "Resource not found page", - Description = "", - GroupName = SiteTabs.SiteStructure, - Order = 10)] - public virtual ContentReference PageNotFound { get; set; } + public virtual ContentReference ResetPasswordPage { get; set; } [Display( Name = "Login registration page", diff --git a/Sources/EPiServer.Reference.Commerce.Site/Global.asax.cs b/Sources/EPiServer.Reference.Commerce.Site/Global.asax.cs index c1c6ada8..45164783 100644 --- a/Sources/EPiServer.Reference.Commerce.Site/Global.asax.cs +++ b/Sources/EPiServer.Reference.Commerce.Site/Global.asax.cs @@ -1,5 +1,8 @@ -using EPiServer.Reference.Commerce.Site.Infrastructure; +using EPiServer.Reference.Commerce.Site.Features.ErrorHandling.Controllers; +using EPiServer.Reference.Commerce.Site.Infrastructure; using EPiServer.Reference.Commerce.Site.Infrastructure.Attributes; +using System; +using System.Web; using System.Web.Mvc; using System.Web.Optimization; using System.Web.Routing; @@ -34,6 +37,53 @@ protected void Application_Start() BundleConfig.RegisterBundles(BundleTable.Bundles); } + protected void Application_Error(object sender, EventArgs e) + { + if (Context.IsCustomErrorEnabled) + { + ShowCustomErrorPage(Server.GetLastError()); + } + } + + private void ShowCustomErrorPage(Exception exception) + { + var httpException = exception as HttpException; + if (httpException == null) + { + httpException = new HttpException(500, "Internal Server Error", exception); + } + + Response.Clear(); + var routeData = new RouteData(); + routeData.Values.Add("controller", "ErrorHandling"); + routeData.Values.Add("fromAppErrorEvent", true); + + switch (httpException.GetHttpCode()) + { + case 403: + routeData.Values.Add("action", "Forbidden"); + break; + + case 404: + routeData.Values.Add("action", "PageNotFound"); + break; + + case 500: + routeData.Values.Add("action", "InternalError"); + break; + + default: + routeData.Values.Add("action", "OtherHttpStatusCode"); + routeData.Values.Add("httpStatusCode", httpException.GetHttpCode()); + break; + } + + Server.ClearError(); + + IController controller = new ErrorHandlingController(); + controller.Execute(new RequestContext(new HttpContextWrapper(Context), routeData)); + } + protected void Application_EndRequest() { if (Context.Response.StatusCode == 302 diff --git a/Sources/EPiServer.Reference.Commerce.Site/Views/Bundle/Index.cshtml b/Sources/EPiServer.Reference.Commerce.Site/Views/Bundle/Index.cshtml index 04e3f52a..9c468f47 100644 --- a/Sources/EPiServer.Reference.Commerce.Site/Views/Bundle/Index.cshtml +++ b/Sources/EPiServer.Reference.Commerce.Site/Views/Bundle/Index.cshtml @@ -40,20 +40,17 @@
- @if (!(bool)ViewData["IsReadOnly"]) + @using (Html.BeginForm("AddToCart", "Cart", FormMethod.Post, new { @class = "form-inline", data_container = "MiniCart" })) { - using (Html.BeginForm("AddToCart", "Cart", FormMethod.Post, new { @class = "form-inline", data_container = "MiniCart" })) + @Html.Hidden("code", Model.Bundle.Code) + + } + @if (User.Identity.IsAuthenticated && !(bool)ViewData["IsReadOnly"]) + { + using (Html.BeginForm("AddToCart", "WishList", FormMethod.Post, new { @class = "form-inline jsAddToWishList", data_container = "WishListMiniCart" })) { @Html.Hidden("code", Model.Bundle.Code) - - } - if (User.Identity.IsAuthenticated) - { - using (Html.BeginForm("AddToCart", "WishList", FormMethod.Post, new { @class = "form-inline jsAddToWishList", data_container = "WishListMiniCart" })) - { - @Html.Hidden("code", Model.Bundle.Code) - - } + } }
diff --git a/Sources/EPiServer.Reference.Commerce.Site/Views/Bundle/_Quickview.cshtml b/Sources/EPiServer.Reference.Commerce.Site/Views/Bundle/_Quickview.cshtml index a63314f8..23abacee 100644 --- a/Sources/EPiServer.Reference.Commerce.Site/Views/Bundle/_Quickview.cshtml +++ b/Sources/EPiServer.Reference.Commerce.Site/Views/Bundle/_Quickview.cshtml @@ -31,37 +31,33 @@
- @if (!(bool)ViewData["IsReadOnly"]) + @using (Html.BeginForm("AddToCart", "Cart", FormMethod.Post, new { @class = "form-inline", data_container = "MiniCart" })) { - using (Html.BeginForm("AddToCart", "Cart", FormMethod.Post, new { @class = "form-inline", data_container = "MiniCart" })) + @Html.Hidden("code", Model.Bundle.Code) + + } + @if (User.Identity.IsAuthenticated && !(bool)ViewData["IsReadOnly"]) + { + using (Html.BeginForm("AddToCart", "WishList", FormMethod.Post, new { @class = "form-inline jsAddToWishList", data_container = "WishListMiniCart" })) { @Html.Hidden("code", Model.Bundle.Code) - + } - if (User.Identity.IsAuthenticated) - { - using (Html.BeginForm("AddToCart", "WishList", FormMethod.Post, new { @class = "form-inline jsAddToWishList", data_container = "WishListMiniCart" })) - { - @Html.Hidden("code", Model.Bundle.Code) - - } - } - - if (Functions.ShouldRenderTrackingSection()) - { - - } + }