Skip to content

Commit

Permalink
Resolves #528 LimitedToStores is required on payment provider rather …
Browse files Browse the repository at this point in the history
…than plugin level
  • Loading branch information
mgesing committed Feb 9, 2018
1 parent c5fd992 commit c3d9d3f
Show file tree
Hide file tree
Showing 23 changed files with 344 additions and 339 deletions.
1 change: 1 addition & 0 deletions changelog.md
Expand Up @@ -70,6 +70,7 @@
* Payment-Filter: Fixed "The cast to value type 'System.Decimal' failed because the materialized value is null"
* The tax value per tax rate was not updated when adding\removing a product to\from the order.
* The option to send manually was ignored when sending e-mails
* #528 LimitedToStores is required on payment provider rather than plugin level


## SmartStore.NET 3.0.3
Expand Down
18 changes: 3 additions & 15 deletions src/Libraries/SmartStore.Core/Domain/Directory/Country.cs
Expand Up @@ -2,19 +2,17 @@
using System.ComponentModel.DataAnnotations;
using System.Runtime.Serialization;
using SmartStore.Core.Domain.Localization;
using SmartStore.Core.Domain.Shipping;
using SmartStore.Core.Domain.Stores;

namespace SmartStore.Core.Domain.Directory
{
/// <summary>
/// Represents a country
/// </summary>
/// <summary>
/// Represents a country
/// </summary>
[DataContract]
public partial class Country : BaseEntity, ILocalizedEntity, IStoreMappingSupported
{
private ICollection<StateProvince> _stateProvinces;
private ICollection<ShippingMethod> _restrictedShippingMethods;

/// <summary>
/// Gets or sets the name
Expand Down Expand Up @@ -90,15 +88,5 @@ public virtual ICollection<StateProvince> StateProvinces
get { return _stateProvinces ?? (_stateProvinces = new HashSet<StateProvince>()); }
protected set { _stateProvinces = value; }
}

/// <summary>
/// Gets or sets the restricted shipping methods
/// </summary>
public virtual ICollection<ShippingMethod> RestrictedShippingMethods
{
get { return _restrictedShippingMethods ?? (_restrictedShippingMethods = new HashSet<ShippingMethod>()); }
protected set { _restrictedShippingMethods = value; }
}
}

}
11 changes: 9 additions & 2 deletions src/Libraries/SmartStore.Core/Domain/Payments/PaymentMethod.cs
@@ -1,13 +1,14 @@
using System.Runtime.Serialization;
using SmartStore.Core.Domain.Localization;
using SmartStore.Core.Domain.Stores;

namespace SmartStore.Core.Domain.Payments
{
/// <summary>
/// Represents a payment method
/// </summary>
[DataContract]
public partial class PaymentMethod : BaseEntity, ILocalizedEntity
public partial class PaymentMethod : BaseEntity, ILocalizedEntity, IStoreMappingSupported
{
/// <summary>
/// Gets or sets the payment method system name
Expand All @@ -27,5 +28,11 @@ public partial class PaymentMethod : BaseEntity, ILocalizedEntity
/// <see cref="https://en.wikipedia.org/wiki/Cash_rounding"/>
[DataMember]
public bool RoundOrderTotalEnabled { get; set; }
}

/// <summary>
/// Gets or sets a value indicating whether the entity is limited/restricted to certain stores
/// </summary>
[DataMember]
public bool LimitedToStores { get; set; }
}
}
14 changes: 0 additions & 14 deletions src/Libraries/SmartStore.Core/Domain/Shipping/ShippingMethod.cs
@@ -1,6 +1,4 @@
using System.Collections.Generic;
using System.Runtime.Serialization;
using SmartStore.Core.Domain.Directory;
using SmartStore.Core.Domain.Localization;
using SmartStore.Core.Domain.Stores;

Expand All @@ -12,8 +10,6 @@ namespace SmartStore.Core.Domain.Shipping
[DataContract]
public partial class ShippingMethod : BaseEntity, ILocalizedEntity, IStoreMappingSupported
{
private ICollection<Country> _restrictedCountries;

/// <summary>
/// Gets or sets the name
/// </summary>
Expand Down Expand Up @@ -43,15 +39,5 @@ public partial class ShippingMethod : BaseEntity, ILocalizedEntity, IStoreMappin
/// </summary>
[DataMember]
public bool LimitedToStores { get; set; }

/// <summary>
/// Gets or sets the restricted countries
/// </summary>
[DataMember]
public virtual ICollection<Country> RestrictedCountries
{
get { return _restrictedCountries ?? (_restrictedCountries = new HashSet<Country>()); }
protected set { _restrictedCountries = value; }
}
}
}
Expand Up @@ -3,18 +3,14 @@

namespace SmartStore.Data.Mapping.Shipping
{
public class ShippingMethodMap : EntityTypeConfiguration<ShippingMethod>
public class ShippingMethodMap : EntityTypeConfiguration<ShippingMethod>
{
public ShippingMethodMap()
{
this.ToTable("ShippingMethod");
this.HasKey(sm => sm.Id);
ToTable("ShippingMethod");
HasKey(sm => sm.Id);

this.Property(sm => sm.Name).IsRequired().HasMaxLength(400);

this.HasMany(sm => sm.RestrictedCountries)
.WithMany(c => c.RestrictedShippingMethods)
.Map(m => m.ToTable("ShippingMethodRestrictions"));
Property(sm => sm.Name).IsRequired().HasMaxLength(400);
}
}
}

This file was deleted.

This file was deleted.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

@@ -0,0 +1,38 @@
namespace SmartStore.Data.Migrations
{
using System;
using System.Data.Entity.Migrations;

public partial class ShippingMethodMultistore : DbMigration
{
public override void Up()
{
DropForeignKey("dbo.ShippingMethodRestrictions", "ShippingMethod_Id", "dbo.ShippingMethod");
DropForeignKey("dbo.ShippingMethodRestrictions", "Country_Id", "dbo.Country");
DropIndex("dbo.ShippingMethodRestrictions", new[] { "ShippingMethod_Id" });
DropIndex("dbo.ShippingMethodRestrictions", new[] { "Country_Id" });
AddColumn("dbo.ShippingMethod", "LimitedToStores", c => c.Boolean(nullable: false));
AddColumn("dbo.PaymentMethod", "LimitedToStores", c => c.Boolean(nullable: false));
DropTable("dbo.ShippingMethodRestrictions");
}

public override void Down()
{
CreateTable(
"dbo.ShippingMethodRestrictions",
c => new
{
ShippingMethod_Id = c.Int(nullable: false),
Country_Id = c.Int(nullable: false),
})
.PrimaryKey(t => new { t.ShippingMethod_Id, t.Country_Id });

DropColumn("dbo.PaymentMethod", "LimitedToStores");
DropColumn("dbo.ShippingMethod", "LimitedToStores");
CreateIndex("dbo.ShippingMethodRestrictions", "Country_Id");
CreateIndex("dbo.ShippingMethodRestrictions", "ShippingMethod_Id");
AddForeignKey("dbo.ShippingMethodRestrictions", "Country_Id", "dbo.Country", "Id", cascadeDelete: true);
AddForeignKey("dbo.ShippingMethodRestrictions", "ShippingMethod_Id", "dbo.ShippingMethod", "Id", cascadeDelete: true);
}
}
}

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions src/Libraries/SmartStore.Data/SmartStore.Data.csproj
Expand Up @@ -553,9 +553,9 @@
<Compile Include="Migrations\201712290151517_AddressFormat.Designer.cs">
<DependentUpon>201712290151517_AddressFormat.cs</DependentUpon>
</Compile>
<Compile Include="Migrations\201802081135066_ShippingMethodMultistore.cs" />
<Compile Include="Migrations\201802081135066_ShippingMethodMultistore.Designer.cs">
<DependentUpon>201802081135066_ShippingMethodMultistore.cs</DependentUpon>
<Compile Include="Migrations\201802081830029_ShippingMethodMultistore.cs" />
<Compile Include="Migrations\201802081830029_ShippingMethodMultistore.Designer.cs">
<DependentUpon>201802081830029_ShippingMethodMultistore.cs</DependentUpon>
</Compile>
<Compile Include="ObjectContextBase.SaveChanges.cs" />
<Compile Include="Setup\Builder\ActivityLogTypeMigrator.cs" />
Expand Down Expand Up @@ -1006,8 +1006,8 @@
<EmbeddedResource Include="Migrations\201712290151517_AddressFormat.resx">
<DependentUpon>201712290151517_AddressFormat.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Migrations\201802081135066_ShippingMethodMultistore.resx">
<DependentUpon>201802081135066_ShippingMethodMultistore.cs</DependentUpon>
<EmbeddedResource Include="Migrations\201802081830029_ShippingMethodMultistore.resx">
<DependentUpon>201802081830029_ShippingMethodMultistore.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Sql\Indexes.sql" />
<EmbeddedResource Include="Sql\StoredProcedures.sql" />
Expand Down
7 changes: 5 additions & 2 deletions src/Libraries/SmartStore.Services/Payments/IPaymentService.cs
Expand Up @@ -41,22 +41,25 @@ public partial interface IPaymentService
/// Load payment provider by system name
/// </summary>
/// <param name="systemName">System name</param>
/// <param name="onlyWhenActive"><c>true</c> to load only active provider</param>
/// <param name="storeId">Load records allowed only in specified store; pass 0 to load all records</param>
/// <returns>Found payment provider</returns>
Provider<IPaymentMethod> LoadPaymentMethodBySystemName(string systemName, bool onlyWhenActive = false, int storeId = 0);

/// <summary>
/// Load all payment providers
/// </summary>
/// <param name="storeId">Load records allows only in specified store; pass 0 to load all records</param>
/// <param name="storeId">Load records allowed only in specified store; pass 0 to load all records</param>
/// <returns>Payment providers</returns>
IEnumerable<Provider<IPaymentMethod>> LoadAllPaymentMethods(int storeId = 0);


/// <summary>
/// Gets all payment method extra data
/// </summary>
/// <param name="storeId">Load records allowed only in specified store; pass 0 to load all records</param>
/// <returns>List of payment method objects</returns>
IList<PaymentMethod> GetAllPaymentMethods();
IList<PaymentMethod> GetAllPaymentMethods(int storeId = 0);

/// <summary>
/// Gets payment method extra data by system name
Expand Down

0 comments on commit c3d9d3f

Please sign in to comment.