Skip to content

Commit

Permalink
Migração para versão 4.20
Browse files Browse the repository at this point in the history
  • Loading branch information
rdakar committed Aug 29, 2019
1 parent 7e98824 commit 69f963e
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 12 deletions.
4 changes: 3 additions & 1 deletion BlogPlugin.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.Collections.Generic;
using Nop.Core;
using Nop.Core.Plugins;
using Nop.Services.Plugins;
using Nop.Services.Cms;
using Nop.Services.Configuration;
using Nop.Services.Localization;
Expand Down Expand Up @@ -56,5 +56,7 @@ public override void Uninstall()
}

public string GetWidgetViewComponentName(string widgetZone) => "WidgetsBlog";

public bool HideInWidgetList => false;
}
}
22 changes: 18 additions & 4 deletions Controllers/WidgetsBlogController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,37 @@
using Nop.Web.Framework;
using Microsoft.AspNetCore.Mvc;
using Nop.Services.Localization;
using Nop.Services.Security;
using Nop.Services.Messages;
using Nop.Web.Framework.Mvc.Filters;

namespace NopBrasil.Plugin.Widgets.Blog.Controllers
{
[AuthorizeAdmin]
[Area(AreaNames.Admin)]
public class WidgetsBlogController : BasePluginController
{
private readonly ISettingService _settingService;
private readonly ILocalizationService _localizationService;
private readonly BlogSettings _BlogSettings;
private readonly INotificationService _notificationService;
private readonly IPermissionService _permissionService;

public WidgetsBlogController(ISettingService settingService, ILocalizationService localizationService,
BlogSettings BlogSettings)
BlogSettings BlogSettings, INotificationService notificationService, IPermissionService permissionService)
{
this._settingService = settingService;
this._localizationService = localizationService;
this._BlogSettings = BlogSettings;
this._notificationService = notificationService;
this._permissionService = permissionService;
}

public ActionResult Configure()
public IActionResult Configure()
{
if (!_permissionService.Authorize(StandardPermissionProvider.ManageShippingSettings))
return AccessDeniedView();

var model = new ConfigurationModel()
{
WidgetZone = _BlogSettings.WidgetZone,
Expand All @@ -33,15 +44,18 @@ public ActionResult Configure()
}

[HttpPost]
public ActionResult Configure(ConfigurationModel model)
public IActionResult Configure(ConfigurationModel model)
{
if (!_permissionService.Authorize(StandardPermissionProvider.ManageShippingSettings))
return AccessDeniedView();

if (!ModelState.IsValid)
return Configure();

_BlogSettings.QtdBlogPosts = model.QtdBlogPosts;
_BlogSettings.WidgetZone = model.WidgetZone;
_settingService.SaveSetting(_BlogSettings);
SuccessNotification(_localizationService.GetResource("Admin.Plugins.Saved"));
_notificationService.SuccessNotification(_localizationService.GetResource("Admin.Plugins.Saved"));
return Configure();
}
}
Expand Down
15 changes: 9 additions & 6 deletions NopBrasil.Plugin.Widgets.Blog.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>
<TargetFramework>netcoreapp2.2</TargetFramework>
<Copyright>Copyright © nopCommerce Brasil</Copyright>
<Company>nopCommerce Brasil</Company>
<Authors>nopCommerce Brasil - www.nopcommercebrasil.com - [email protected]</Authors>
Expand All @@ -12,17 +12,17 @@
<RepositoryType>Git</RepositoryType>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<OutputPath>..\nopCommerce410\Presentation\Nop.Web\Plugins\Widgets.Blog\</OutputPath>
<OutputPath>..\nopCommerce420\src\Presentation\Nop.Web\Plugins\Widgets.Blog\</OutputPath>
<OutDir>$(OutputPath)</OutDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<OutputPath>..\nopCommerce410\Presentation\Nop.Web\Plugins\Widgets.Blog\</OutputPath>
<OutputPath>..\nopCommerce420\src\Presentation\Nop.Web\Plugins\Widgets.Blog\</OutputPath>
<OutDir>$(OutputPath)</OutDir>
</PropertyGroup>
<!-- This target execute after "Build" target -->
<Target Name="NopTarget" AfterTargets="Build">
<!-- Delete unnecessary libraries from plugins path -->
<MSBuild Projects="$(MSBuildProjectDirectory)\..\nopCommerce410\Build\ClearPluginAssemblies.proj" Properties="PluginPath=$(MSBuildProjectDirectory)\$(OutDir)" Targets="NopClear" />
<MSBuild Projects="@(ClearPluginAssemblies)" Properties="PluginPath=$(MSBuildProjectDirectory)\$(OutDir)" Targets="NopClear" />
</Target>
<ItemGroup>
<None Remove="Content\Images\nopCommerceBrasil.png" />
Expand Down Expand Up @@ -51,9 +51,12 @@
<Content Include="Views\_ViewImports.cshtml">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
</ItemGroup>
<ItemGroup>
<ClearPluginAssemblies Include="$(MSBuildProjectDirectory)\..\nopCommerce420\src\Build\ClearPluginAssemblies.proj" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\nopCommerce410\Presentation\Nop.Web.Framework\Nop.Web.Framework.csproj" />
<ProjectReference Include="..\nopCommerce410\Presentation\Nop.Web\Nop.Web.csproj" />
<ProjectReference Include="..\nopCommerce420\src\Presentation\Nop.Web.Framework\Nop.Web.Framework.csproj" />
<ProjectReference Include="..\nopCommerce420\src\Presentation\Nop.Web\Nop.Web.csproj" />
</ItemGroup>
</Project>
2 changes: 1 addition & 1 deletion plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"FriendlyName": "Blog",
"SystemName": "Widgets.Blog",
"Version": "1.00",
"SupportedVersions": [ "4.10" ],
"SupportedVersions": [ "4.20" ],
"Author": "nopCommerce Brasil - www.nopcommercebrasil.com - [email protected]",
"DisplayOrder": 1,
"FileName": "NopBrasil.Plugin.Widgets.Blog.dll",
Expand Down

0 comments on commit 69f963e

Please sign in to comment.