Browse Source

Upgraded bookstore sample.

pull/341/head
Halil ibrahim Kalkan 8 years ago
parent
commit
4877a38e5b
  1. 2
      samples/BookStore/src/Acme.BookStore.Application/Acme.BookStore.Application.csproj
  2. 2
      samples/BookStore/src/Acme.BookStore.Application/BookStoreApplicationAutoMapperProfile.cs
  3. 4
      samples/BookStore/src/Acme.BookStore.Application/IBookAppService.cs
  4. 2
      samples/BookStore/src/Acme.BookStore.Domain/Acme.BookStore.Domain.csproj
  5. 2
      samples/BookStore/src/Acme.BookStore.Domain/Book.cs
  6. 2
      samples/BookStore/src/Acme.BookStore.Domain/BookStoreDomainModule.cs
  7. 4
      samples/BookStore/src/Acme.BookStore.Domain/Localization/BookStore/en.json
  8. 4
      samples/BookStore/src/Acme.BookStore.Domain/Localization/BookStore/tr.json
  9. 8
      samples/BookStore/src/Acme.BookStore.EntityFrameworkCore/Acme.BookStore.EntityFrameworkCore.csproj
  10. 9
      samples/BookStore/src/Acme.BookStore.EntityFrameworkCore/Migrations/20180528221424_Initial.Designer.cs
  11. 1
      samples/BookStore/src/Acme.BookStore.EntityFrameworkCore/Migrations/20180528221424_Initial.cs
  12. 2
      samples/BookStore/src/Acme.BookStore.EntityFrameworkCore/Migrations/20180703184727_Created_Book_Entity.Designer.cs
  13. 0
      samples/BookStore/src/Acme.BookStore.EntityFrameworkCore/Migrations/20180703184727_Created_Book_Entity.cs
  14. 10
      samples/BookStore/src/Acme.BookStore.Web/Acme.BookStore.Web.csproj
  15. 2
      samples/BookStore/src/Acme.BookStore.Web/BookStoreWebAutoMapperProfile.cs
  16. 37
      samples/BookStore/src/Acme.BookStore.Web/BookStoreWebModule.cs
  17. 2
      samples/BookStore/src/Acme.BookStore.Web/Pages/Books/EditModal.cshtml
  18. 2
      samples/BookStore/src/Acme.BookStore.Web/Pages/Books/EditModal.cshtml.cs
  19. 16
      samples/BookStore/src/Acme.BookStore.Web/Pages/Books/Index.cshtml
  20. 6
      samples/BookStore/src/Acme.BookStore.Web/Pages/Books/Index.cshtml.cs
  21. 4
      samples/BookStore/src/Acme.BookStore.Web/Properties/launchSettings.json
  22. 79
      samples/BookStore/src/Acme.BookStore.Web/wwwroot/pages/books/index.js
  23. 8
      samples/BookStore/test/Acme.BookStore.Application.Tests/Acme.BookStore.Application.Tests.csproj
  24. 6
      samples/BookStore/test/Acme.BookStore.Application.Tests/BookAppService_Tests.cs
  25. 4
      samples/BookStore/test/Acme.BookStore.Web.Tests/Acme.BookStore.Web.Tests.csproj

2
samples/BookStore/src/Acme.BookStore.Application/Acme.BookStore.Application.csproj

@ -7,7 +7,7 @@
<ItemGroup>
<ProjectReference Include="..\Acme.BookStore.Domain\Acme.BookStore.Domain.csproj" />
<PackageReference Include="Volo.Abp.Identity.Application" Version="0.3.4" />
<PackageReference Include="Volo.Abp.Identity.Application" Version="0.3.5" />
</ItemGroup>
</Project>

2
samples/BookStore/src/Acme.BookStore.Application/BookStoreApplicationAutoMapperProfile.cs

@ -6,7 +6,7 @@ namespace Acme.BookStore
{
public BookStoreApplicationAutoMapperProfile()
{
//add your custom AutoMapper configuration
//Configure your AutoMapper mapping configuration here...
}
}
}

4
samples/BookStore/src/Acme.BookStore.Application/IBookAppService.cs

@ -4,7 +4,7 @@ using Volo.Abp.Application.Services;
namespace Acme.BookStore
{
public interface IBookAppService :
public interface IBookAppService :
IAsyncCrudAppService< //Defines CRUD methods
BookDto, //Used to show books
Guid, //Primary key of the book entity
@ -14,4 +14,4 @@ namespace Acme.BookStore
{
}
}
}

2
samples/BookStore/src/Acme.BookStore.Domain/Acme.BookStore.Domain.csproj

@ -6,7 +6,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Volo.Abp.Identity.Domain" Version="0.3.4" />
<PackageReference Include="Volo.Abp.Identity.Domain" Version="0.3.5" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.DataAnnotations" Version="2.1.1" />
</ItemGroup>

2
samples/BookStore/src/Acme.BookStore.Domain/Book.cs

@ -18,4 +18,4 @@ namespace Acme.BookStore
public float Price { get; set; }
}
}
}

2
samples/BookStore/src/Acme.BookStore.Domain/BookStoreDomainModule.cs

@ -3,6 +3,7 @@ using Acme.BookStore.Localization.BookStore;
using Acme.BookStore.Settings;
using Volo.Abp.Identity;
using Volo.Abp.Localization;
using Volo.Abp.Localization.Resources.AbpValidation;
using Volo.Abp.Modularity;
using Volo.Abp.Settings;
using Volo.Abp.VirtualFileSystem;
@ -23,6 +24,7 @@ namespace Acme.BookStore
{
options.Resources
.Add<BookStoreResource>("en")
.AddBaseTypes(typeof(AbpValidationResource))
.AddVirtualJson("/Localization/BookStore");
});

4
samples/BookStore/src/Acme.BookStore.Domain/Localization/BookStore/en.json

@ -2,10 +2,10 @@
"culture": "en",
"texts": {
"Menu:Home": "Home",
"Menu:BookStore": "Book Store",
"Menu:Books": "Books",
"Welcome": "Welcome",
"LongWelcomeMessage": "Welcome to the application. This is a startup project based on the ABP framework. For more information, visit abp.io.",
"Menu:BookStore": "Book Store",
"Menu:Books": "Books",
"Name": "Name",
"Type": "Type",
"PublishDate": "Publish Date",

4
samples/BookStore/src/Acme.BookStore.Domain/Localization/BookStore/tr.json

@ -2,10 +2,10 @@
"culture": "tr",
"texts": {
"Menu:Home": "Ana sayfa",
"Menu:BookStore": "Kitap Deposu",
"Menu:Books": "Kitaplar",
"Welcome": "Hoşgeldiniz",
"LongWelcomeMessage": "Uygulamaya hoşgeldiniz. Bu, ABP framework'ü üzerine bina edilmiş bir başlangıç projesidir. Daha fazla bilgi için abp.io adresini ziyaret edebilirsiniz.",
"Menu:BookStore": "Kitap Mağazası",
"Menu:Books": "Kitaplar",
"Name": "İsim",
"Type": "Tür",
"PublishDate": "Yayınlanma Tarihi",

8
samples/BookStore/src/Acme.BookStore.EntityFrameworkCore/Acme.BookStore.EntityFrameworkCore.csproj

@ -12,10 +12,10 @@
<ItemGroup>
<ProjectReference Include="..\Acme.BookStore.Domain\Acme.BookStore.Domain.csproj" />
<PackageReference Include="Volo.Abp.PermissionManagement.EntityFrameworkCore" Version="0.3.4" />
<PackageReference Include="Volo.Abp.SettingManagement.EntityFrameworkCore" Version="0.3.4" />
<PackageReference Include="Volo.Abp.Identity.EntityFrameworkCore" Version="0.3.4" />
<PackageReference Include="Volo.Abp.EntityFrameworkCore.SqlServer" Version="0.3.4" />
<PackageReference Include="Volo.Abp.PermissionManagement.EntityFrameworkCore" Version="0.3.5" />
<PackageReference Include="Volo.Abp.SettingManagement.EntityFrameworkCore" Version="0.3.5" />
<PackageReference Include="Volo.Abp.Identity.EntityFrameworkCore" Version="0.3.5" />
<PackageReference Include="Volo.Abp.EntityFrameworkCore.SqlServer" Version="0.3.5" />
</ItemGroup>
</Project>

9
samples/BookStore/src/Acme.BookStore.EntityFrameworkCore/Migrations/20180701195241_Initial.Designer.cs → samples/BookStore/src/Acme.BookStore.EntityFrameworkCore/Migrations/20180528221424_Initial.Designer.cs

@ -1,24 +1,25 @@
// <auto-generated />
using System;
using Acme.BookStore.EntityFrameworkCore;
using System.Collections.Generic;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Metadata.Internal;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Acme.BookStore.EntityFrameworkCore;
namespace Acme.BookStore.Migrations
{
[DbContext(typeof(BookStoreDbContext))]
[Migration("20180701195241_Initial")]
[Migration("20180528221424_Initial")]
partial class Initial
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "2.1.1-rtm-30846")
.HasAnnotation("Relational:MaxIdentifierLength", 128)
.HasAnnotation("ProductVersion", "2.1.0-preview2-30571")
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
modelBuilder.Entity("Volo.Abp.Identity.IdentityRole", b =>

1
samples/BookStore/src/Acme.BookStore.EntityFrameworkCore/Migrations/20180701195241_Initial.cs → samples/BookStore/src/Acme.BookStore.EntityFrameworkCore/Migrations/20180528221424_Initial.cs

@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;
using Microsoft.EntityFrameworkCore.Migrations;
namespace Acme.BookStore.Migrations

2
samples/BookStore/src/Acme.BookStore.EntityFrameworkCore/Migrations/20180701195424_Created_Book_Entity.Designer.cs → samples/BookStore/src/Acme.BookStore.EntityFrameworkCore/Migrations/20180703184727_Created_Book_Entity.Designer.cs

@ -10,7 +10,7 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
namespace Acme.BookStore.Migrations
{
[DbContext(typeof(BookStoreDbContext))]
[Migration("20180701195424_Created_Book_Entity")]
[Migration("20180703184727_Created_Book_Entity")]
partial class Created_Book_Entity
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)

0
samples/BookStore/src/Acme.BookStore.EntityFrameworkCore/Migrations/20180701195424_Created_Book_Entity.cs → samples/BookStore/src/Acme.BookStore.EntityFrameworkCore/Migrations/20180703184727_Created_Book_Entity.cs

10
samples/BookStore/src/Acme.BookStore.Web/Acme.BookStore.Web.csproj

@ -18,7 +18,7 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.1.1" />
<PackageReference Include="Microsoft.AspNetCore.App" Version="2.1.1" />
<PackageReference Include="Serilog.AspNetCore" Version="2.1.1" />
<PackageReference Include="Serilog.Sinks.File" Version="4.0.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="2.5.0" />
@ -27,10 +27,10 @@
<ItemGroup>
<ProjectReference Include="..\Acme.BookStore.Application\Acme.BookStore.Application.csproj" />
<ProjectReference Include="..\Acme.BookStore.EntityFrameworkCore\Acme.BookStore.EntityFrameworkCore.csproj" />
<PackageReference Include="Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic" Version="0.3.4" />
<PackageReference Include="Volo.Abp.Autofac" Version="0.3.4" />
<PackageReference Include="Volo.Abp.Identity.Web" Version="0.3.4" />
<PackageReference Include="Volo.Abp.Account.Web" Version="0.3.4" />
<PackageReference Include="Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic" Version="0.3.5" />
<PackageReference Include="Volo.Abp.Autofac" Version="0.3.5" />
<PackageReference Include="Volo.Abp.Identity.Web" Version="0.3.5" />
<PackageReference Include="Volo.Abp.Account.Web" Version="0.3.5" />
</ItemGroup>
</Project>

2
samples/BookStore/src/Acme.BookStore.Web/BookStoreWebAutoMapperProfile.cs

@ -6,7 +6,7 @@ namespace Acme.BookStore
{
public BookStoreWebAutoMapperProfile()
{
//add your custom AutoMapper configuration
//Configure your AutoMapper mapping configuration here...
}
}
}

37
samples/BookStore/src/Acme.BookStore.Web/BookStoreWebModule.cs

@ -17,6 +17,8 @@ using Volo.Abp.Account.Web;
using Volo.Abp.AspNetCore.Modularity;
using Volo.Abp.AspNetCore.Mvc;
using Volo.Abp.AspNetCore.Mvc.Localization;
using Volo.Abp.AspNetCore.Mvc.UI;
using Volo.Abp.AspNetCore.Mvc.UI.Bootstrap;
using Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic;
using Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared;
using Volo.Abp.Autofac;
@ -28,7 +30,9 @@ using Volo.Abp.Identity.Web;
using Volo.Abp.Localization;
using Volo.Abp.Localization.Resources.AbpValidation;
using Volo.Abp.Modularity;
using Volo.Abp.PermissionManagement.Web;
using Volo.Abp.Threading;
using Volo.Abp.UI;
using Volo.Abp.UI.Navigation;
using Volo.Abp.VirtualFileSystem;
@ -69,34 +73,26 @@ namespace Acme.BookStore
ConfigureNavigationServices(services);
ConfigureAutoApiControllers(services);
ConfigureSwaggerServices(services);
services.AddAssemblyOf<BookStoreWebModule>();
}
private static void ConfigureAutoMapper(IServiceCollection services)
private static void ConfigureDatabaseServices(IServiceCollection services, IConfigurationRoot configuration)
{
services.Configure<AbpAutoMapperOptions>(options =>
services.Configure<DbConnectionOptions>(options =>
{
options.AddProfile<BookStoreWebAutoMapperProfile>(validate: true);
options.ConnectionStrings.Default = configuration.GetConnectionString("Default");
});
}
private static void ConfigureAutoApiControllers(IServiceCollection services)
{
services.Configure<AbpAspNetCoreMvcOptions>(options =>
{
options.ConventionalControllers.Create(typeof(BookStoreApplicationModule).Assembly);
});
services.Configure<AbpDbContextOptions>(options => { options.UseSqlServer(); });
}
private static void ConfigureDatabaseServices(IServiceCollection services, IConfigurationRoot configuration)
private static void ConfigureAutoMapper(IServiceCollection services)
{
services.Configure<DbConnectionOptions>(options =>
services.Configure<AbpAutoMapperOptions>(options =>
{
options.ConnectionStrings.Default = configuration.GetConnectionString("Default");
options.AddProfile<BookStoreWebAutoMapperProfile>();
});
services.Configure<AbpDbContextOptions>(options => { options.UseSqlServer(); });
}
private static void ConfigureVirtualFileSystem(IServiceCollection services, IHostingEnvironment hostingEnvironment)
@ -106,6 +102,7 @@ namespace Acme.BookStore
services.Configure<VirtualFileSystemOptions>(options =>
{
options.FileSets.ReplaceEmbeddedByPyhsical<BookStoreDomainModule>(Path.Combine(hostingEnvironment.ContentRootPath, "..\\Acme.BookStore.Domain"));
});
}
}
@ -139,6 +136,14 @@ namespace Acme.BookStore
});
}
private static void ConfigureAutoApiControllers(IServiceCollection services)
{
services.Configure<AbpAspNetCoreMvcOptions>(options =>
{
options.ConventionalControllers.Create(typeof(BookStoreApplicationModule).Assembly);
});
}
private static void ConfigureSwaggerServices(IServiceCollection services)
{
services.AddSwaggerGen(

2
samples/BookStore/src/Acme.BookStore.Web/Pages/Books/EditModal.cshtml

@ -11,7 +11,7 @@
<abp-modal-header title="@L["Update"].Value"></abp-modal-header>
<abp-modal-body>
<abp-input asp-for="Id" />
<abp-form-content/>
<abp-form-content />
</abp-modal-body>
<abp-modal-footer buttons="@(AbpModalButtons.Cancel|AbpModalButtons.Save)"></abp-modal-footer>
</abp-modal>

2
samples/BookStore/src/Acme.BookStore.Web/Pages/Books/EditModal.cshtml.cs

@ -12,7 +12,7 @@ namespace Acme.BookStore.Pages.Books
[BindProperty]
public CreateUpdateBookDto Book { get; set; }
private readonly IBookAppService _bookAppService;
public EditModalModel(IBookAppService bookAppService)

16
samples/BookStore/src/Acme.BookStore.Web/Pages/Books/Index.cshtml

@ -23,14 +23,14 @@
<abp-card-body>
<abp-table striped-rows="true" id="BooksTable">
<thead>
<tr>
<th>@L["Actions"]</th>
<th>@L["Name"]</th>
<th>@L["Type"]</th>
<th>@L["PublishDate"]</th>
<th>@L["Price"]</th>
<th>@L["CreationTime"]</th>
</tr>
<tr>
<th>@L["Actions"]</th>
<th>@L["Name"]</th>
<th>@L["Type"]</th>
<th>@L["PublishDate"]</th>
<th>@L["Price"]</th>
<th>@L["CreationTime"]</th>
</tr>
</thead>
</abp-table>
</abp-card-body>

6
samples/BookStore/src/Acme.BookStore.Web/Pages/Books/Index.cshtml.cs

@ -1,3 +1,8 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
namespace Acme.BookStore.Pages.Books
@ -6,7 +11,6 @@ namespace Acme.BookStore.Pages.Books
{
public void OnGet()
{
}
}
}

4
samples/BookStore/src/Acme.BookStore.Web/Properties/launchSettings.json

@ -3,7 +3,7 @@
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:54929/",
"applicationUrl": "http://localhost:53929/",
"sslPort": 0
}
},
@ -21,7 +21,7 @@
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"applicationUrl": "http://localhost:54932/"
"applicationUrl": "http://localhost:53932/"
}
}
}

79
samples/BookStore/src/Acme.BookStore.Web/wwwroot/pages/books/index.js

@ -5,69 +5,44 @@
var createModal = new abp.ModalManager(abp.appPath + 'Books/CreateModal');
var editModal = new abp.ModalManager(abp.appPath + 'Books/EditModal');
var dataTable = $('#BooksTable').DataTable({
var dataTable = $('#BooksTable').DataTable(abp.libs.datatables.normalizeConfiguration({
order: [[1, "asc"]],
ajax: abp.libs.datatables.createAjax(acme.bookStore.book.getList),
columnDefs: [
{
targets: 0,
data: null,
orderable: false,
autoWidth: false,
defaultContent: '',
rowAction: {
text: '<i class="fa fa-cog"></i> ' + l('Actions') + ' <span class="caret"></span>',
items:
[
{
text: l('Edit'),
visible: function () { return true; },
action: function (data) {
editModal.open({
id: data.record.id
});
}
[
{
text: l('Edit'),
action: function (data) {
editModal.open({ id: data.record.id });
}
},
{
text: l('Delete'),
confirmMessage: function (data) {
return l('BookDeletionConfirmationMessage', data.record.name);
},
{
text: l('Delete'),
visible: function () { return true; },
confirmMessage: function (data) {
return l('BookDeletionConfirmationMessage', data.record.name);
},
action: function (data) {
acme.bookStore.book
.delete(data.record.id)
.then(function () {
abp.notify.info(l('SuccessfullyDeleted'));
dataTable.ajax.reload();
});
}
action: function (data) {
acme.bookStore.book
.delete(data.record.id)
.then(function() {
abp.notify.info(l('SuccessfullyDeleted'));
dataTable.ajax.reload();
});
}
]
}
]
}
},
{
targets: 1,
data: "name"
},
{
targets: 2,
data: "type"
},
{
targets: 3,
data: "publishDate"
},
{
targets: 4,
data: "price"
},
{
targets: 5,
data: "creationTime"
}
{ data: "name" },
{ data: "type" },
{ data: "publishDate" },
{ data: "price" },
{ data: "creationTime" }
]
});
}));
createModal.onResult(function () {
dataTable.ajax.reload();

8
samples/BookStore/test/Acme.BookStore.Application.Tests/Acme.BookStore.Application.Tests.csproj

@ -8,19 +8,19 @@
<ItemGroup>
<ProjectReference Include="..\..\src\Acme.BookStore.Application\Acme.BookStore.Application.csproj" />
<ProjectReference Include="..\..\src\Acme.BookStore.EntityFrameworkCore\Acme.BookStore.EntityFrameworkCore.csproj" />
<PackageReference Include="Volo.Abp.TestBase" Version="0.3.3" />
<PackageReference Include="Volo.Abp.Autofac" Version="0.3.3" />
<PackageReference Include="Volo.Abp.TestBase" Version="0.3.5" />
<PackageReference Include="Volo.Abp.Autofac" Version="0.3.5" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.7.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.7.2" />
<PackageReference Include="NSubstitute" Version="3.1.0" />
<PackageReference Include="Shouldly" Version="3.0.0" />
<PackageReference Include="xunit" Version="2.3.1" />
<PackageReference Include="xunit.extensibility.execution" Version="2.3.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.3.1" />
<PackageReference Include="Microsoft.Data.Sqlite" Version="2.1.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="2.1.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="2.1.1" />
</ItemGroup>
</Project>

6
samples/BookStore/test/Acme.BookStore.Application.Tests/BookAppService_Tests.cs

@ -21,7 +21,9 @@ namespace Acme.BookStore
public async Task Should_Get_List_Of_Books()
{
//Act
var result = await _bookAppService.GetListAsync(new PagedAndSortedResultRequestDto());
var result = await _bookAppService.GetListAsync(
new PagedAndSortedResultRequestDto()
);
//Assert
result.TotalCount.ShouldBeGreaterThan(0);
@ -67,4 +69,4 @@ namespace Acme.BookStore
.ShouldContain(err => err.MemberNames.Any(mem => mem == "Name"));
}
}
}
}

4
samples/BookStore/test/Acme.BookStore.Web.Tests/Acme.BookStore.Web.Tests.csproj

@ -12,10 +12,10 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.7.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.7.2" />
<ProjectReference Include="..\Acme.BookStore.Application.Tests\Acme.BookStore.Application.Tests.csproj" />
<ProjectReference Include="..\..\src\Acme.BookStore.Web\Acme.BookStore.Web.csproj" />
<PackageReference Include="Volo.Abp.AspNetCore.TestBase" Version="0.3.3" />
<PackageReference Include="Volo.Abp.AspNetCore.TestBase" Version="0.3.5" />
</ItemGroup>
<ItemGroup>

Loading…
Cancel
Save