Merge branch 'dev' into remove-async-apis

pull/2464/head
Halil İbrahim Kalkan 6 years ago
commit 93e89ba9a2

@ -1,13 +1,22 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Options;
using Volo.Abp.AspNetCore.Mvc;
using Volo.Blogging;
namespace Volo.BloggingTestApp.Controllers
{
public class HomeController : AbpController
{
private readonly BloggingUrlOptions _blogOptions;
public HomeController(IOptions<BloggingUrlOptions> blogOptions)
{
_blogOptions = blogOptions.Value;
}
public ActionResult Index()
{
return Redirect("/blog/");
var urlPrefix = _blogOptions.RoutePrefix;
return Redirect(urlPrefix);
}
}
}

@ -4,6 +4,7 @@ using System.Net;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Options;
using Volo.Abp.AspNetCore.Mvc.UI.RazorPages;
using Volo.Blogging.Blogs;
using Volo.Blogging.Blogs.Dtos;
@ -16,6 +17,7 @@ namespace Volo.Blogging.Pages.Blog.Posts
private readonly IPostAppService _postAppService;
private readonly IBlogAppService _blogAppService;
private readonly IAuthorizationService _authorization;
private readonly BloggingUrlOptions _blogOptions;
[BindProperty(SupportsGet = true)]
public string BlogShortName { get; set; }
@ -25,11 +27,12 @@ namespace Volo.Blogging.Pages.Blog.Posts
public BlogDto Blog { get; set; }
public NewModel(IPostAppService postAppService, IBlogAppService blogAppService, IAuthorizationService authorization)
public NewModel(IPostAppService postAppService, IBlogAppService blogAppService, IAuthorizationService authorization, IOptions<BloggingUrlOptions> blogOptions)
{
_postAppService = postAppService;
_blogAppService = blogAppService;
_authorization = authorization;
_blogOptions = blogOptions.Value;
}
public async Task<ActionResult> OnGetAsync()
@ -54,7 +57,8 @@ namespace Volo.Blogging.Pages.Blog.Posts
var postWithDetailsDto = await _postAppService.CreateAsync(ObjectMapper.Map<CreatePostViewModel,CreatePostDto>(Post));
//TODO: Try Url.Page(...)
return Redirect(Url.Content($"~/blog/{WebUtility.UrlEncode(blog.ShortName)}/{WebUtility.UrlEncode(postWithDetailsDto.Url)}"));
var urlPrefix = _blogOptions.RoutePrefix;
return Redirect(Url.Content($"~{urlPrefix}{WebUtility.UrlEncode(blog.ShortName)}/{WebUtility.UrlEncode(postWithDetailsDto.Url)}"));
}
public class CreatePostViewModel

Loading…
Cancel
Save