mirror of https://github.com/abpframework/abp
parent
4a75e5f52b
commit
3e090ba964
@ -0,0 +1,19 @@
|
||||
@page
|
||||
@using Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Modal
|
||||
@inherits ProductManagement.Pages.ProductManagement.ProductManagementPage
|
||||
@model ProductManagement.Pages.ProductManagement.Products.CreateModel
|
||||
@{
|
||||
Layout = null;
|
||||
}
|
||||
|
||||
|
||||
<abp-dynamic-form submit-button="false" abp-model="Product" asp-page="/ProductManagement/Products/Create">
|
||||
<abp-modal size="@(AbpModalSize.Large)">
|
||||
<abp-modal-header title="@L["Create"].Value"></abp-modal-header>
|
||||
<abp-modal-body>
|
||||
<abp-form-content />
|
||||
</abp-modal-body>
|
||||
<abp-modal-footer buttons="@(AbpModalButtons.Cancel|AbpModalButtons.Save)">
|
||||
</abp-modal-footer>
|
||||
</abp-modal>
|
||||
</abp-dynamic-form>
|
||||
@ -0,0 +1,49 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Volo.Abp.AspNetCore.Mvc.UI.RazorPages;
|
||||
|
||||
namespace ProductManagement.Pages.ProductManagement.Products
|
||||
{
|
||||
public class CreateModel : AbpPageModel
|
||||
{
|
||||
private readonly IProductAppService _productAppService;
|
||||
|
||||
[BindProperty]
|
||||
public ProductCreateModalView Product { get; set; } = new ProductCreateModalView();
|
||||
|
||||
public CreateModel(IProductAppService productAppService)
|
||||
{
|
||||
_productAppService = productAppService;
|
||||
}
|
||||
|
||||
public void OnGet()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public async Task<IActionResult> OnPostAsync()
|
||||
{
|
||||
var createProductDto = ObjectMapper.Map<ProductCreateModalView, CreateProductDto>(Product);
|
||||
|
||||
await _productAppService.CreateAsync(createProductDto);
|
||||
|
||||
return NoContent();
|
||||
}
|
||||
|
||||
public class ProductCreateModalView
|
||||
{
|
||||
[Required]
|
||||
[StringLength(ProductConsts.MaxCodeLength)]
|
||||
public string Code { get; set; }
|
||||
|
||||
[Required]
|
||||
[StringLength(ProductConsts.MaxNameLength)]
|
||||
public string Name { get; set; }
|
||||
|
||||
public float Price { get; set; }
|
||||
|
||||
public int StockCount { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,18 @@
|
||||
@page
|
||||
@using Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Modal
|
||||
@inherits ProductManagement.Pages.ProductManagement.ProductManagementPage
|
||||
@model ProductManagement.Pages.ProductManagement.Products.EditModel
|
||||
@{
|
||||
Layout = null;
|
||||
}
|
||||
|
||||
<abp-dynamic-form submit-button="false" abp-model="Product" asp-page="/ProductManagement/Products/Edit">
|
||||
<abp-modal size="@(AbpModalSize.Large)">
|
||||
<abp-modal-header title="@L["Edit"].Value"></abp-modal-header>
|
||||
<abp-modal-body>
|
||||
<abp-form-content />
|
||||
</abp-modal-body>
|
||||
<abp-modal-footer buttons="@(AbpModalButtons.Cancel|AbpModalButtons.Save)">
|
||||
</abp-modal-footer>
|
||||
</abp-modal>
|
||||
</abp-dynamic-form>
|
||||
@ -0,0 +1,67 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
using Volo.Abp.AspNetCore.Mvc.UI.RazorPages;
|
||||
|
||||
namespace ProductManagement.Pages.ProductManagement.Products
|
||||
{
|
||||
public class EditModel : AbpPageModel
|
||||
{
|
||||
private readonly IProductAppService _productAppService;
|
||||
|
||||
[BindProperty]
|
||||
public ProductEditModalView Product { get; set; } = new ProductEditModalView();
|
||||
|
||||
public EditModel(IProductAppService productAppService)
|
||||
{
|
||||
_productAppService = productAppService;
|
||||
}
|
||||
|
||||
public void OnGet()
|
||||
{
|
||||
}
|
||||
|
||||
public async Task<ActionResult> OnGetAsync(Guid productId)
|
||||
{
|
||||
var productDto = await _productAppService.GetAsync(productId);
|
||||
|
||||
Product = ObjectMapper.Map<ProductDto, ProductEditModalView>(productDto);
|
||||
|
||||
return Page();
|
||||
}
|
||||
|
||||
public async Task OnPostAsync()
|
||||
{
|
||||
await _productAppService.UpdateAsync(Product.Id, new UpdateProductDto()
|
||||
{
|
||||
Code = Product.Code,
|
||||
Name = Product.Name,
|
||||
Price = Product.Price,
|
||||
StockCount = Product.StockCount
|
||||
});
|
||||
}
|
||||
|
||||
public class ProductEditModalView
|
||||
{
|
||||
[HiddenInput]
|
||||
[Required]
|
||||
public Guid Id { get; set; }
|
||||
|
||||
[Required]
|
||||
[StringLength(ProductConsts.MaxCodeLength)]
|
||||
public string Code { get; set; }
|
||||
|
||||
[Required]
|
||||
[StringLength(ProductConsts.MaxNameLength)]
|
||||
public string Name { get; set; }
|
||||
|
||||
public float Price { get; set; }
|
||||
|
||||
public int StockCount { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,42 @@
|
||||
@page
|
||||
@using Microsoft.AspNetCore.Authorization
|
||||
@using ProductManagement
|
||||
@inherits ProductManagement.Pages.ProductManagement.ProductManagementPage
|
||||
@model ProductManagement.Pages.ProductManagement.Products.IndexModel
|
||||
@inject IAuthorizationService Authorization
|
||||
@{
|
||||
ViewBag.PageTitle = "Products";
|
||||
}
|
||||
|
||||
@section scripts {
|
||||
<abp-script src="/Pages/ProductManagement/Products/index.js" />
|
||||
}
|
||||
|
||||
<abp-card>
|
||||
<abp-card-header>
|
||||
<abp-row>
|
||||
<abp-column size-md="_6">
|
||||
<h2>@L["Products"]</h2>
|
||||
</abp-column>
|
||||
<abp-column size-md="_6" class="text-right">
|
||||
@if (await Authorization.IsGrantedAsync(ProductManagementPermissions.Products.Create))
|
||||
{
|
||||
<abp-button icon="plus" text="@L["CreateANewProduct"].Value" button-type="Primary" id="CreateNewProductButtonId"></abp-button>
|
||||
}
|
||||
</abp-column>
|
||||
</abp-row>
|
||||
</abp-card-header>
|
||||
<abp-card-body>
|
||||
<abp-table striped-rows="true" id="ProductsTable" class="nowrap">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>@L["Actions"]</th>
|
||||
<th>@L["Code"]</th>
|
||||
<th>@L["Name"]</th>
|
||||
<th>@L["Price"]</th>
|
||||
<th>@L["StockCount"]</th>
|
||||
</tr>
|
||||
</thead>
|
||||
</abp-table>
|
||||
</abp-card-body>
|
||||
</abp-card>
|
||||
@ -0,0 +1,12 @@
|
||||
using System.Threading.Tasks;
|
||||
using Volo.Abp.AspNetCore.Mvc.UI.RazorPages;
|
||||
|
||||
namespace ProductManagement.Pages.ProductManagement.Products
|
||||
{
|
||||
public class IndexModel : AbpPageModel
|
||||
{
|
||||
public async Task OnGetAsync()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in new issue