Browse Source

Added posts controller.

pull/81/head
Halil İbrahim Kalkan 10 years ago
parent
commit
d363619288
  1. 6
      src/AbpDesk/AbpDesk.Web.Mvc/AbpDeskWebMvcModule.cs
  2. 35
      src/AbpDesk/AbpDesk.Web.Mvc/Areas/Blog/Controllers/PostsController.cs
  3. 24
      src/AbpDesk/AbpDesk.Web.Mvc/Areas/Blog/Views/Posts/Index.cshtml
  4. 3
      src/AbpDesk/AbpDesk.Web.Mvc/Navigation/MainMenuContributor.cs
  5. 3
      src/AbpDesk/AbpDesk.Web.Mvc/appsettings.json
  6. 3
      src/AbpDesk/AbpDesk.Web.Mvc/project.json
  7. 2
      src/Volo.Abp.Identity.Application/Volo/Abp/Identity/UserAppService.cs

6
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
{

35
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<BlogPost> _blogPostRepository;
private readonly IUnitOfWorkManager _unitOfWorkManager;
public PostsController(IQueryableRepository<BlogPost> blogPostRepository, IUnitOfWorkManager unitOfWorkManager)
{
_blogPostRepository = blogPostRepository;
_unitOfWorkManager = unitOfWorkManager;
}
public async Task<ActionResult> Index()
{
using (var unitOfWork = _unitOfWorkManager.Begin())
{
var posts = await _blogPostRepository.GetListAsync(HttpContext.RequestAborted);
await unitOfWork.CompleteAsync(HttpContext.RequestAborted);
return View(posts);
}
}
}
}

24
src/AbpDesk/AbpDesk.Web.Mvc/Areas/Blog/Views/Posts/Index.cshtml

@ -0,0 +1,24 @@
@model List<AbpDesk.Blogging.BlogPost>
<h2>Blog Posts</h2>
<ul>
@foreach (var post in Model)
{
<h3>@post.Title</h3>
<p>@post.Body</p>
if (!post.Comments.Any())
{
<p><em>No comment yet!</em></p>
}
else
{
<h4>Comments</h4>
foreach (var comment in post.Comments)
{
<h5>@comment.Name</h5>
<p>@comment.Message</p>
}
}
}
</ul>

3
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;

3
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": {

3
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": {

2
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;

Loading…
Cancel
Save