diff --git a/src/AbpDesk/AbpDesk.Web.Mvc/AbpDeskWebMvcModule.cs b/src/AbpDesk/AbpDesk.Web.Mvc/AbpDeskWebMvcModule.cs index 4e8bb2b92a..50efa49ca3 100644 --- a/src/AbpDesk/AbpDesk.Web.Mvc/AbpDeskWebMvcModule.cs +++ b/src/AbpDesk/AbpDesk.Web.Mvc/AbpDeskWebMvcModule.cs @@ -1,4 +1,5 @@ -using AbpDesk.EntityFrameworkCore; +using AbpDesk.Blogging; +using AbpDesk.EntityFrameworkCore; using AbpDesk.Web.Mvc.Navigation; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; @@ -22,7 +23,8 @@ namespace AbpDesk.Web.Mvc typeof(AbpDeskApplicationModule), typeof(AbpDeskEntityFrameworkCoreModule), typeof(AbpIdentityHttpProxyModule), - typeof(AbpIdentityWebModule) + typeof(AbpIdentityWebModule), + typeof(AbpDeskMongoBlogModule) )] public class AbpDeskWebMvcModule : AbpModule { diff --git a/src/AbpDesk/AbpDesk.Web.Mvc/Areas/Blog/Controllers/PostsController.cs b/src/AbpDesk/AbpDesk.Web.Mvc/Areas/Blog/Controllers/PostsController.cs new file mode 100644 index 0000000000..01ea8d6b6d --- /dev/null +++ b/src/AbpDesk/AbpDesk.Web.Mvc/Areas/Blog/Controllers/PostsController.cs @@ -0,0 +1,35 @@ +using System.Threading.Tasks; +using AbpDesk.Blogging; +using Microsoft.AspNetCore.Mvc; +using Volo.Abp.AspNetCore.Mvc; +using Volo.Abp.Domain.Repositories; +using Volo.Abp.Uow; + +namespace AbpDesk.Web.Mvc.Areas.Blog.Controllers +{ + //TODO: Move this controller to a plug-in + [Area("Blog")] + public class PostsController : AbpController + { + private readonly IQueryableRepository _blogPostRepository; + private readonly IUnitOfWorkManager _unitOfWorkManager; + + public PostsController(IQueryableRepository blogPostRepository, IUnitOfWorkManager unitOfWorkManager) + { + _blogPostRepository = blogPostRepository; + _unitOfWorkManager = unitOfWorkManager; + } + + public async Task Index() + { + using (var unitOfWork = _unitOfWorkManager.Begin()) + { + var posts = await _blogPostRepository.GetListAsync(HttpContext.RequestAborted); + + await unitOfWork.CompleteAsync(HttpContext.RequestAborted); + + return View(posts); + } + } + } +} diff --git a/src/AbpDesk/AbpDesk.Web.Mvc/Areas/Blog/Views/Posts/Index.cshtml b/src/AbpDesk/AbpDesk.Web.Mvc/Areas/Blog/Views/Posts/Index.cshtml new file mode 100644 index 0000000000..39c6c5c4ed --- /dev/null +++ b/src/AbpDesk/AbpDesk.Web.Mvc/Areas/Blog/Views/Posts/Index.cshtml @@ -0,0 +1,24 @@ +@model List + +

Blog Posts

+ +
    + @foreach (var post in Model) + { +

    @post.Title

    +

    @post.Body

    + if (!post.Comments.Any()) + { +

    No comment yet!

    + } + else + { +

    Comments

    + foreach (var comment in post.Comments) + { +
    @comment.Name
    +

    @comment.Message

    + } + } + } +
\ No newline at end of file diff --git a/src/AbpDesk/AbpDesk.Web.Mvc/Navigation/MainMenuContributor.cs b/src/AbpDesk/AbpDesk.Web.Mvc/Navigation/MainMenuContributor.cs index 10f578ff42..2c3efe861d 100644 --- a/src/AbpDesk/AbpDesk.Web.Mvc/Navigation/MainMenuContributor.cs +++ b/src/AbpDesk/AbpDesk.Web.Mvc/Navigation/MainMenuContributor.cs @@ -22,6 +22,9 @@ namespace AbpDesk.Web.Mvc.Navigation .AddItem( new ApplicationMenuItem("TicketManagement.Tickets", "Tickets", url: "/Tickets") ) + ) + .AddItem( + new ApplicationMenuItem("Blog", "Blog", url: "/Blog/Posts") ); return Task.CompletedTask; diff --git a/src/AbpDesk/AbpDesk.Web.Mvc/appsettings.json b/src/AbpDesk/AbpDesk.Web.Mvc/appsettings.json index 41ba6612ea..626f4317d8 100644 --- a/src/AbpDesk/AbpDesk.Web.Mvc/appsettings.json +++ b/src/AbpDesk/AbpDesk.Web.Mvc/appsettings.json @@ -1,6 +1,7 @@ { "ConnectionStrings": { - "Default": "Server=localhost;Database=AbpDesk;Trusted_Connection=True;" + "Default": "Server=localhost;Database=AbpDesk;Trusted_Connection=True;", + "AbpDeskMongoBlog": "mongodb://127.0.0.1:27017|AbpDeskBlog" }, "AbpIdentity": { "HttpProxy": { diff --git a/src/AbpDesk/AbpDesk.Web.Mvc/project.json b/src/AbpDesk/AbpDesk.Web.Mvc/project.json index 6a586c11c1..bd4b160ac2 100644 --- a/src/AbpDesk/AbpDesk.Web.Mvc/project.json +++ b/src/AbpDesk/AbpDesk.Web.Mvc/project.json @@ -27,7 +27,8 @@ "Volo.Abp.AspNetCore.Mvc.UI.Bootstrap": "1.0.0-*", "Volo.Abp.AspNetCore.EmbeddedFiles": "1.0.0-*", "Volo.Abp.Identity.HttpProxy": "1.0.0-*", - "Volo.Abp.Identity.Web": "1.0.0-*" + "Volo.Abp.Identity.Web": "1.0.0-*", + "AbpDesk.MongoBlog": "1.0.0-*" }, "tools": { diff --git a/src/Volo.Abp.Identity.Application/Volo/Abp/Identity/UserAppService.cs b/src/Volo.Abp.Identity.Application/Volo/Abp/Identity/UserAppService.cs index 5cafc579fb..4ed91fe363 100644 --- a/src/Volo.Abp.Identity.Application/Volo/Abp/Identity/UserAppService.cs +++ b/src/Volo.Abp.Identity.Application/Volo/Abp/Identity/UserAppService.cs @@ -6,6 +6,8 @@ using Volo.Abp.Uow; namespace Volo.Abp.Identity { + //TODO: Consider a way of passing cancellation token to all async application service methods! + public class UserAppService : IUserAppService { private readonly IIdentityUserRepository _userRepository;