Skip to content

Commit 87e3bf0

Browse files
authored
Merge pull request #27 from Geta/net6
Net6
2 parents 961b9dc + 0f207b2 commit 87e3bf0

File tree

132 files changed

+763
-759
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

132 files changed

+763
-759
lines changed

sandbox/Foundation/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
<a href="https://github.com/episerver/Foundation"><img src="https://www.optimizely.com/globalassets/02.-global-images/navigation/optimizely_logo_navigation.svg" title="Foundation" alt="Foundation"></a>
22

3+
# Latest version
4+
This version is built for net6.0. For the legacy full framework version please use the [full-framework/master](https://github.com/episerver/Foundation/tree/full-framework/master)
5+
36
## Foundation
47

58
Foundation offers a starting point that is intuitive, well-structured and modular allowing developers to explore CMS, Commerce, Personalization, Search amd Navigaion, Data Platform and Experimentation.
Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
using EPiServer;
2+
using EPiServer.Framework.Blobs;
3+
using EPiServer.Logging;
4+
using Mediachase.Commerce.Catalog.ImportExport;
5+
using Microsoft.AspNetCore.Http;
6+
using Microsoft.AspNetCore.Mvc;
7+
using System;
8+
using System.Collections.Generic;
9+
using System.Linq;
10+
using System.Net.Http;
11+
using System.Threading.Tasks;
12+
using Mediachase.Commerce.Catalog;
13+
using EPiServer.Commerce.Catalog.ContentTypes;
14+
using System.IO;
15+
using System.IO.Compression;
16+
using System.Net.Http.Headers;
17+
using Microsoft.Net.Http.Headers;
18+
using EPiServer.Authorization;
19+
using Microsoft.AspNetCore.Authorization;
20+
21+
namespace Foundation.Features.Api
22+
{
23+
24+
[ApiController]
25+
[Route("[controller]")]
26+
public class CatalogExportController : ControllerBase
27+
{
28+
private readonly CatalogImportExport _importExport;
29+
private readonly IBlobFactory _blobFactory;
30+
private readonly IContentLoader _contentLoader;
31+
private readonly ReferenceConverter _referenceConverter;
32+
internal const string DownloadRoute = "episerverapi/catalogs/";
33+
private static readonly Guid _blobContainerIdentifier = Guid.Parse("119AD01E-ECD1-4781-898B-6DEC356FC8D8");
34+
35+
private static readonly ILogger _logger = LogManager.GetLogger(typeof(CatalogExportController));
36+
37+
38+
/// <summary>
39+
/// Initializes a new instance of the <see cref="CatalogExportController"/> class.
40+
/// </summary>
41+
/// <param name="importExport">Catalog import export</param>
42+
/// <param name="blobFactory">The blob factory.</param>
43+
/// <param name="contentLoader">The content loader.</param>
44+
/// <param name="referenceConverter"></param>
45+
public CatalogExportController(CatalogImportExport importExport,
46+
IBlobFactory blobFactory,
47+
IContentLoader contentLoader,
48+
ReferenceConverter referenceConverter)
49+
{
50+
_importExport = importExport;
51+
_blobFactory = blobFactory;
52+
_contentLoader = contentLoader;
53+
_referenceConverter = referenceConverter;
54+
_importExport.IsModelsAvailable = true;
55+
}
56+
57+
58+
59+
// GET: CatalogExportController
60+
[HttpGet]
61+
[Authorize(Roles = "CommerceAdmins")]
62+
[Route(DownloadRoute)]
63+
public ActionResult Index(string catalogName)
64+
{
65+
var catalogs = _contentLoader.GetChildren<EPiServer.Commerce.Catalog.ContentTypes.CatalogContent >(_referenceConverter.GetRootLink());
66+
var catalog = catalogs.FirstOrDefault(x => x.Name.Equals(catalogName, StringComparison.OrdinalIgnoreCase));
67+
if (catalog != null)
68+
{
69+
return Ok(GetFile(catalog.Name));
70+
}
71+
72+
return Ok(string.Format("{0} not found", catalogName)) ;
73+
74+
}
75+
76+
private Task GetFile(string catalogName)
77+
{
78+
var container = Blob.GetContainerIdentifier(_blobContainerIdentifier);
79+
var blob = _blobFactory.CreateBlob(container, ".zip");
80+
using (var stream = blob.OpenWrite())
81+
{
82+
using (var zipArchive = new ZipArchive(stream, ZipArchiveMode.Create, false))
83+
{
84+
var entry = zipArchive.CreateEntry("catalog.xml");
85+
86+
using (var entryStream = entry.Open())
87+
{
88+
_importExport.Export(catalogName, entryStream, Path.GetTempPath());
89+
}
90+
}
91+
}
92+
93+
94+
HttpContext.Response.ContentType = "application/zip";
95+
var sourceStream = blob.OpenRead();// get the source stream
96+
return sourceStream.CopyToAsync(HttpContext.Response.Body);
97+
98+
99+
}
100+
101+
//[HttpGet]
102+
//[Route("streaming")]
103+
//public async Task GetStreaming()
104+
//{
105+
// const string filePath = @"C:\Users\mike\Downloads\dotnet-sdk-3.1.201-win-x64.exe";
106+
// this.Response.StatusCode = 200;
107+
// this.Response.Headers.Add(HeaderNames.ContentDisposition, $"attachment; filename=\"{Path.GetFileName(filePath)}\"");
108+
// this.Response.Headers.Add(HeaderNames.ContentType, "application/octet-stream");
109+
// var inputStream = new FileStream(filePath, FileMode.Open, FileAccess.Read);
110+
// var outputStream = this.Response.Body;
111+
// const int bufferSize = 1 << 10;
112+
// var buffer = new byte[bufferSize];
113+
// while (true)
114+
// {
115+
// var bytesRead = await inputStream.ReadAsync(buffer, 0, bufferSize);
116+
// if (bytesRead == 0) break;
117+
// await outputStream.WriteAsync(buffer, 0, bytesRead);
118+
// }
119+
// await outputStream.FlushAsync();
120+
//}
121+
}
122+
}

sandbox/Foundation/src/Foundation/Features/Api/PublicApiController.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,6 @@ public async Task<ActionResult> RegisterAccount(RegisterAccountViewModel viewMod
103103
FirstName = viewModel.Address.FirstName,
104104
LastName = viewModel.Address.LastName,
105105
RegistrationSource = "Registration page",
106-
NewsLetter = viewModel.Newsletter,
107106
IsApproved = true
108107
};
109108

sandbox/Foundation/src/Foundation/Features/Blocks/ButtonBlock/ButtonBlock.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public class ButtonBlock : FoundationBlockData
4545

4646
[CultureSpecific]
4747
[Searchable(false)]
48-
[ClientEditor(ClientEditingClass = "foundation/editors/ColorPicker")]
48+
[ClientEditor(ClientEditingClass = "foundation/Editors/ColorPicker")]
4949
[Display(Name = "Button Text color", GroupName = TabNames.Text, Order = 50)]
5050
public virtual string ButtonTextColor
5151
{
@@ -69,7 +69,7 @@ public virtual string ButtonTextColor
6969

7070
[CultureSpecific]
7171
[Searchable(false)]
72-
[ClientEditor(ClientEditingClass = "foundation/editors/ColorPicker")]
72+
[ClientEditor(ClientEditingClass = "foundation/Editors/ColorPicker")]
7373
[Display(Name = "Button background color", GroupName = TabNames.Background, Order = 20)]
7474
public virtual string ButtonBackgroundColor
7575
{
@@ -96,7 +96,7 @@ public virtual string ButtonBackgroundColor
9696

9797
[CultureSpecific]
9898
[Searchable(false)]
99-
[ClientEditor(ClientEditingClass = "foundation/editors/ColorPicker")]
99+
[ClientEditor(ClientEditingClass = "foundation/Editors/ColorPicker")]
100100
[Display(Name = "Button Border color", GroupName = TabNames.Border, Order = 30)]
101101
public virtual string ButtonBorderColor
102102
{

sandbox/Foundation/src/Foundation/Features/Blocks/CallToActionBlock/CallToActionBlock.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public class CallToActionBlock : FoundationBlockData//, IDashboardItem
2626
public virtual XhtmlString Subtext { get; set; }
2727

2828
[Display(Name = "Text color", GroupName = SystemTabNames.Content, Order = 30)]
29-
[ClientEditor(ClientEditingClass = "foundation/editors/ColorPicker")]
29+
[ClientEditor(ClientEditingClass = "foundation/Editors/ColorPicker")]
3030
public virtual string TextColor { get; set; }
3131
#endregion
3232

sandbox/Foundation/src/Foundation/Features/Blocks/CommentsBlock/CommentsBlock.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ namespace Foundation.Features.Blocks.CommentsBlock
1313
GUID = "b8a110ff-a8e2-4c17-9706-ce777694ebd4",
1414
Description = "Configures the frontend view properties of a comment block",
1515
GroupName = GroupNames.Social)]
16-
[ImageUrl("~/assets/icons/cms/blocks/cms-icon-block-25.png")]
16+
[ImageUrl("~/icons/cms/blocks/CMS-icon-block-25.png")]
1717
public class CommentsBlock : FoundationBlockData
1818
{
1919
/// <summary>

sandbox/Foundation/src/Foundation/Features/Blocks/CommentsBlock/CommentsBlock.cshtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
@Html.HiddenFor(m => m.CurrentPageLink)
2121
@Html.HiddenFor(m => m.SendActivity)
2222
<div>
23-
@Html.TextArea(name: "Body", htmlAttributes: new
23+
@Html.TextArea("Body", htmlAttributes: new
2424
{
2525
placeholder = "Enter your comment",
2626
maxlength = Model.CommentMaxLength,
Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,18 @@
1-
using EPiServer.Framework.DataAnnotations;
2-
using EPiServer.Web.Routing;
1+
using EPiServer.Web.Routing;
32
using Foundation.Social;
43
using Foundation.Social.Models.ActivityStreams;
54
using Foundation.Social.Models.Comments;
65
using Foundation.Social.Repositories.ActivityStreams;
76
using Foundation.Social.Repositories.Comments;
87
using Foundation.Social.Repositories.Common;
8+
using Microsoft.AspNetCore.Mvc;
99
using System.Collections.Generic;
1010
using System.Linq;
11-
using Microsoft.AspNetCore.Mvc;
11+
using System.Threading.Tasks;
1212

1313
namespace Foundation.Features.Blocks.CommentsBlock
1414
{
15-
[TemplateDescriptor(Default = true)]
16-
public class CommentsBlockController : SocialBlockController<CommentsBlock>
15+
public class CommentsBlockComponent : SocialBlockComponent<CommentsBlock>
1716
{
1817
private readonly IUserRepository _userRepository;
1918
private readonly IPageCommentRepository _commentRepository;
@@ -28,7 +27,7 @@ public class CommentsBlockController : SocialBlockController<CommentsBlock>
2827
/// <summary>
2928
/// Constructor
3029
/// </summary>
31-
public CommentsBlockController(IUserRepository userRepository,
30+
public CommentsBlockComponent(IUserRepository userRepository,
3231
IPageCommentRepository pageCommentRepository,
3332
IPageRepository pageRepository,
3433
ICommunityActivityRepository communityActivityRepository,
@@ -45,7 +44,7 @@ public CommentsBlockController(IUserRepository userRepository,
4544
/// </summary>
4645
/// <param name="currentBlock">The current frontend block instance.</param>
4746
/// <returns>The action's result.</returns>
48-
public override ActionResult Index(CommentsBlock currentBlock)
47+
protected override async Task<IViewComponentResult> InvokeComponentAsync(CommentsBlock currentBlock)
4948
{
5049
var pageReference = _pageRouteHelper.PageLink;
5150
var pageId = _pageRepository.GetPageId(pageReference);
@@ -74,7 +73,7 @@ public override ActionResult Index(CommentsBlock currentBlock)
7473
blockViewModel.Messages.Add(new MessageViewModel(ex.Message, ErrorMessage));
7574
}
7675

77-
return PartialView("~/Features/Blocks/CommentsBlock/CommentsBlock.cshtml", blockViewModel);
76+
return await Task.FromResult(View("~/Features/Blocks/CommentsBlock/CommentsBlock.cshtml", blockViewModel));
7877
}
7978

8079
/// <summary>
@@ -103,7 +102,7 @@ public ActionResult Submit(CommentFormViewModel formViewModel)
103102
AddMessage(MessageKey, new MessageViewModel(errors.First(), ErrorMessage));
104103
}
105104

106-
return Redirect(UrlResolver.Current.GetUrl(formViewModel.CurrentPageLink));
105+
return new RedirectResult(UrlResolver.Current.GetUrl(formViewModel.CurrentPageLink));
107106
}
108107

109108
/// <summary>

sandbox/Foundation/src/Foundation/Features/Blocks/FeedBlock/FeedBlock.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ namespace Foundation.Features.Blocks.FeedBlock
1010
GUID = "2bb4ac6d-6f09-4d38-adb0-5dc2bcf310ac",
1111
Description = "Configures the properties of a feed block frontend view",
1212
GroupName = GroupNames.Social)]
13-
[ImageUrl("~/assets/icons/cms/blocks/cms-icon-block-25.png")]
13+
[ImageUrl("~/icons/cms/blocks/CMS-icon-block-25.png")]
1414
public class FeedBlock : FoundationBlockData
1515
{
1616
/// <summary>

sandbox/Foundation/src/Foundation/Features/Blocks/FeedBlock/FeedBlockController.cs renamed to sandbox/Foundation/src/Foundation/Features/Blocks/FeedBlock/FeedBlockComponent.cs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
using EPiServer.Framework.DataAnnotations;
2-
using EPiServer.Social.ActivityStreams.Core;
1+
using EPiServer.Social.ActivityStreams.Core;
32
using EPiServer.Social.Common;
43
using EPiServer.Web.Routing;
54
using Foundation.Social;
@@ -8,9 +7,10 @@
87
using Foundation.Social.Repositories.ActivityStreams;
98
using Foundation.Social.Repositories.Common;
109
using Foundation.Social.ViewModels;
10+
using Microsoft.AspNetCore.Mvc;
1111
using System.Collections.Generic;
1212
using System.Linq;
13-
using Microsoft.AspNetCore.Mvc;
13+
using System.Threading.Tasks;
1414

1515
namespace Foundation.Features.Blocks.FeedBlock
1616
{
@@ -19,8 +19,7 @@ namespace Foundation.Features.Blocks.FeedBlock
1919
/// generated by the Social Activity Streams system in response to activities occuring on any
2020
/// target items that the logged in user has subscribed to.
2121
/// </summary>
22-
[TemplateDescriptor(Default = true)]
23-
public class FeedBlockController : SocialBlockController<FeedBlock>
22+
public class FeedBlockComponent : SocialBlockComponent<FeedBlock>
2423
{
2524
private readonly IUserRepository _userRepository;
2625
private readonly ICommunityFeedRepository _feedRepository;
@@ -31,7 +30,7 @@ public class FeedBlockController : SocialBlockController<FeedBlock>
3130
/// <summary>
3231
/// Constructor
3332
/// </summary>
34-
public FeedBlockController(IUserRepository userRepository, ICommunityFeedRepository communityFeedRepository, IPageRouteHelper pageRouteHelper,
33+
public FeedBlockComponent(IUserRepository userRepository, ICommunityFeedRepository communityFeedRepository, IPageRouteHelper pageRouteHelper,
3534
ICommunityActivityAdapter communityActivityAdapter) : base(pageRouteHelper)
3635
{
3736
_userRepository = userRepository;
@@ -44,7 +43,7 @@ public FeedBlockController(IUserRepository userRepository, ICommunityFeedReposit
4443
/// </summary>
4544
/// <param name="currentBlock">The current frontend block instance.</param>
4645
/// <returns>The action's result.</returns>
47-
public override ActionResult Index(FeedBlock currentBlock)
46+
protected override async Task<IViewComponentResult> InvokeComponentAsync(FeedBlock currentBlock)
4847
{
4948
// Create a feed block view model to fill the frontend block view
5049
var blockViewModel = new FeedBlockViewModel(currentBlock)
@@ -58,7 +57,7 @@ public override ActionResult Index(FeedBlock currentBlock)
5857
GetSocialActivityFeed(currentBlock, blockViewModel);
5958
}
6059

61-
return PartialView("~/Features/Blocks/FeedBlock/FeedBlock.cshtml", blockViewModel);
60+
return await Task.FromResult(View("~/Features/Blocks/FeedBlock/FeedBlock.cshtml", blockViewModel));
6261
}
6362

6463
/// <summary>

0 commit comments

Comments
 (0)