Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 207d402c66 | |||
| 634aea9fb3 | |||
| 8ffd680a8c | |||
| 97e002404e |
@@ -1,104 +0,0 @@
|
|||||||
using Application.Aggregates.Products.ViewModels;
|
|
||||||
using Application.Aggregates.Stores.ViewModels;
|
|
||||||
using Domain.Aggregates.Products;
|
|
||||||
using Domain.Aggregates.Products.Data;
|
|
||||||
using Domain.Aggregates.Stores;
|
|
||||||
using Mapster;
|
|
||||||
using Persistence.Repositories.Aggregates.Stores;
|
|
||||||
using Resources.Messages;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace Application.Aggregates.Products;
|
|
||||||
|
|
||||||
public class ProductsApplication(IProductRepository productRepository)
|
|
||||||
{
|
|
||||||
public async Task<ProductViewModel> CreateAsync(CreateProductViewModel productViewModel)
|
|
||||||
{
|
|
||||||
var product = Product.Create(
|
|
||||||
name: productViewModel.Name,
|
|
||||||
description: productViewModel.Description,
|
|
||||||
price: productViewModel.Price,
|
|
||||||
quantity: productViewModel.Quantity);
|
|
||||||
|
|
||||||
if (productViewModel.IsActive == true)
|
|
||||||
{
|
|
||||||
product.Activate();
|
|
||||||
}
|
|
||||||
|
|
||||||
await productRepository.AddAsync(product);
|
|
||||||
await productRepository.SaveChangesAsync();
|
|
||||||
|
|
||||||
return product.Adapt<ProductViewModel>();
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task<List<ProductViewModel>> GetStors()
|
|
||||||
{
|
|
||||||
var products =
|
|
||||||
await productRepository.GetAllAsync();
|
|
||||||
|
|
||||||
return products.Adapt<List<ProductViewModel>>();
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task<ProductViewModel> GetAsync(Guid productId)
|
|
||||||
{
|
|
||||||
var product =
|
|
||||||
await productRepository.GetAsync(productId);
|
|
||||||
|
|
||||||
return product.Adapt<ProductViewModel>();
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task<ProductViewModel> UpdateAsync(UpdateProductViewModel updateProductView)
|
|
||||||
{
|
|
||||||
var update =
|
|
||||||
await productRepository.GetAsync(updateProductView.Id);
|
|
||||||
|
|
||||||
if (update == null || updateProductView.Id == Guid.Empty)
|
|
||||||
{
|
|
||||||
var error =
|
|
||||||
string.Format(Errors.NotFound, Resources.DataDictionary.Store);
|
|
||||||
|
|
||||||
throw new Exception(error);
|
|
||||||
}
|
|
||||||
|
|
||||||
update.Update(
|
|
||||||
name: updateProductView.Name,
|
|
||||||
description: updateProductView.Description,
|
|
||||||
price: updateProductView.Price,
|
|
||||||
quantity: updateProductView.Quantity);
|
|
||||||
|
|
||||||
if (updateProductView.IsActive == true)
|
|
||||||
{
|
|
||||||
update.Activate();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
update.Deactivate();
|
|
||||||
}
|
|
||||||
|
|
||||||
await productRepository.SaveChangesAsync();
|
|
||||||
|
|
||||||
return update.Adapt<ProductViewModel>();
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task DeleteAsync(Guid productId)
|
|
||||||
{
|
|
||||||
var delete =
|
|
||||||
await productRepository.GetAsync(productId);
|
|
||||||
|
|
||||||
if (delete == null || delete.Id == Guid.Empty)
|
|
||||||
{
|
|
||||||
var error =
|
|
||||||
string.Format(Errors.NotFound, Resources.DataDictionary.Store);
|
|
||||||
|
|
||||||
throw new Exception(error);
|
|
||||||
}
|
|
||||||
|
|
||||||
productRepository.Remove(delete);
|
|
||||||
|
|
||||||
await productRepository.SaveChangesAsync();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,21 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace Application.Aggregates.Products.ViewModels;
|
|
||||||
|
|
||||||
public class CreateProductViewModel
|
|
||||||
{
|
|
||||||
public CreateProductViewModel()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public string Name { get; set; }
|
|
||||||
public string Description { get; set; }
|
|
||||||
public int Price { get; set; }
|
|
||||||
public int Quantity { get; set; }
|
|
||||||
public bool IsActive { get; set; }
|
|
||||||
}
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace Application.Aggregates.Products.ViewModels;
|
|
||||||
|
|
||||||
public class ProductViewModel : UpdateProductViewModel
|
|
||||||
{
|
|
||||||
}
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace Application.Aggregates.Products.ViewModels;
|
|
||||||
|
|
||||||
public class UpdateProductViewModel:CreateProductViewModel
|
|
||||||
{
|
|
||||||
public Guid Id { get; set; }
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -67,7 +67,7 @@ public class StoresApplication(IStoreRepository storeRepository)
|
|||||||
mobile: updateStoreViewModel.Mobile,
|
mobile: updateStoreViewModel.Mobile,
|
||||||
score: updateStoreViewModel.Score);
|
score: updateStoreViewModel.Score);
|
||||||
|
|
||||||
if (update.IsActive == true)
|
if (updateStoreViewModel.IsActive == true)
|
||||||
{
|
{
|
||||||
update.Activate();
|
update.Activate();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,17 +0,0 @@
|
|||||||
using Domain.Aggregates.Stores;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace Domain.Aggregates.Products.Data;
|
|
||||||
|
|
||||||
public interface IProductRepository
|
|
||||||
{
|
|
||||||
Task AddAsync(Product product);
|
|
||||||
Task<List<Product>> GetAllAsync();
|
|
||||||
Task<Product?> GetAsync(Guid productId);
|
|
||||||
void Remove(Product product);
|
|
||||||
Task SaveChangesAsync();
|
|
||||||
}
|
|
||||||
@@ -1,54 +0,0 @@
|
|||||||
using Domain.Aggregates.Stores;
|
|
||||||
using Domain.SeedWork;
|
|
||||||
using Framework.DataType;
|
|
||||||
using Resources.Messages;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace Domain.Aggregates.Products;
|
|
||||||
|
|
||||||
public class Product : Entity
|
|
||||||
{
|
|
||||||
public Product()
|
|
||||||
{
|
|
||||||
////**********
|
|
||||||
}
|
|
||||||
|
|
||||||
private Product(string name, string description, int price, int quantity)
|
|
||||||
{
|
|
||||||
Name = name;
|
|
||||||
Description = description;
|
|
||||||
Price = price;
|
|
||||||
Quantity = quantity;
|
|
||||||
}
|
|
||||||
|
|
||||||
public string Name { get; set; }
|
|
||||||
public string Description { get; set; }
|
|
||||||
public int Price { get; set; }
|
|
||||||
public int Quantity { get; set; }
|
|
||||||
|
|
||||||
|
|
||||||
public static Product Create(string name, string description, int price, int quantity)
|
|
||||||
{
|
|
||||||
var store = new Product(
|
|
||||||
name: name.Fix() ?? "",
|
|
||||||
description: description.Fix() ?? "",
|
|
||||||
price: price,
|
|
||||||
quantity: quantity);
|
|
||||||
|
|
||||||
return store;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Update(string name, string description, int price, int quantity)
|
|
||||||
{
|
|
||||||
Name = name.Fix() ?? "";
|
|
||||||
Description = description.Fix() ?? "";
|
|
||||||
Price = price;
|
|
||||||
Quantity = quantity;
|
|
||||||
|
|
||||||
SetUpdateDateTime();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,6 +1,5 @@
|
|||||||
using Domain.Aggregates.Stores;
|
using Domain.Aggregates.Stores;
|
||||||
using Domain.Aggregates.Users;
|
using Domain.Aggregates.Users;
|
||||||
using Domain.Aggregates.Products;
|
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
namespace Persistence;
|
namespace Persistence;
|
||||||
@@ -15,6 +14,5 @@ public class DatabaseContext: DbContext
|
|||||||
|
|
||||||
public DbSet<User> Users { get; set; }
|
public DbSet<User> Users { get; set; }
|
||||||
public DbSet<Store> Stores { get; set; }
|
public DbSet<Store> Stores { get; set; }
|
||||||
public DbSet<Product> Products { get; set; }
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,50 +0,0 @@
|
|||||||
using Domain.Aggregates.Products.Data;
|
|
||||||
using Domain.Aggregates.Stores;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using Domain.Aggregates.Products;
|
|
||||||
using Microsoft.EntityFrameworkCore;
|
|
||||||
|
|
||||||
namespace Persistence.Repositories.Aggregates.Products;
|
|
||||||
|
|
||||||
public class ProductRepository(DatabaseContext databaseContext):IProductRepository
|
|
||||||
{
|
|
||||||
public async Task AddAsync(Product product)
|
|
||||||
{
|
|
||||||
await databaseContext.AddAsync(product);
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task<List<Product>> GetAllAsync()
|
|
||||||
{
|
|
||||||
var products =
|
|
||||||
await databaseContext.Products
|
|
||||||
.Where(x => x.IsDeleted == false)
|
|
||||||
.ToListAsync();
|
|
||||||
|
|
||||||
return products;
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task<Product?> GetAsync(Guid productId)
|
|
||||||
{
|
|
||||||
var product =
|
|
||||||
await databaseContext.Products
|
|
||||||
.Where(x => x.IsDeleted == false)
|
|
||||||
.Where(x => x.Id == productId)
|
|
||||||
.FirstOrDefaultAsync();
|
|
||||||
|
|
||||||
return product;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Remove(Product product)
|
|
||||||
{
|
|
||||||
product.Delete();
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task SaveChangesAsync()
|
|
||||||
{
|
|
||||||
await databaseContext.SaveChangesAsync();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -8,5 +8,4 @@
|
|||||||
<h2 class="text-start">Pages</h2>
|
<h2 class="text-start">Pages</h2>
|
||||||
<a class="btn btn-secondary my-2" asp-page="Panel/Users/Index">[ Users ]</a>
|
<a class="btn btn-secondary my-2" asp-page="Panel/Users/Index">[ Users ]</a>
|
||||||
<a class="btn btn-secondary my-2" asp-page="Panel/Stores/Index">[ Stores ]</a>
|
<a class="btn btn-secondary my-2" asp-page="Panel/Stores/Index">[ Stores ]</a>
|
||||||
<a class="btn btn-secondary my-2" asp-page="Panel/Products/Index">[ Products ]</a>
|
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,42 +0,0 @@
|
|||||||
@page
|
|
||||||
@model Server.Pages.Panel.Products.CreateModel
|
|
||||||
@{
|
|
||||||
var pageTitle =
|
|
||||||
$"{Resources.DataDictionary.CreateOf} {Resources.DataDictionary.Product}";
|
|
||||||
|
|
||||||
ViewData[Constants.ViewDataKeyName.PageTitle] = pageTitle;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
<form method="post">
|
|
||||||
|
|
||||||
<section-form>
|
|
||||||
|
|
||||||
<fieldset>
|
|
||||||
|
|
||||||
<section-form-header>
|
|
||||||
@(pageTitle)
|
|
||||||
</section-form-header>
|
|
||||||
|
|
||||||
<partial name="PartialViews/_DisplayPageMessages" />
|
|
||||||
|
|
||||||
|
|
||||||
<ub-full-input asp-for="createProductView.Name" />
|
|
||||||
|
|
||||||
<ub-full-input asp-for="createProductView.Description" />
|
|
||||||
|
|
||||||
<ub-full-input asp-for="createProductView.Price" />
|
|
||||||
|
|
||||||
<ub-full-input asp-for="createProductView.Quantity" />
|
|
||||||
|
|
||||||
<ub-full-checkbox asp-for="createProductView.IsActive" />
|
|
||||||
|
|
||||||
</fieldset>
|
|
||||||
|
|
||||||
<section-form-buttons>
|
|
||||||
<button-create />
|
|
||||||
<button-reset />
|
|
||||||
</section-form-buttons>
|
|
||||||
|
|
||||||
</section-form>
|
|
||||||
|
|
||||||
</form>
|
|
||||||
@@ -1,30 +0,0 @@
|
|||||||
using Application.Aggregates.Products;
|
|
||||||
using Application.Aggregates.Products.ViewModels;
|
|
||||||
using Application.Aggregates.Stores;
|
|
||||||
using Application.Aggregates.Stores.ViewModels;
|
|
||||||
using Microsoft.AspNetCore.Mvc;
|
|
||||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
|
||||||
|
|
||||||
namespace Server.Pages.Panel.Products;
|
|
||||||
|
|
||||||
public class CreateModel(ProductsApplication productsApplication) : PageModel
|
|
||||||
{
|
|
||||||
[BindProperty]
|
|
||||||
public CreateProductViewModel createProductView { get; set; }
|
|
||||||
|
|
||||||
public void OnGet()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task<IActionResult> OnPostAsync()
|
|
||||||
{
|
|
||||||
if (!ModelState.IsValid)
|
|
||||||
{
|
|
||||||
return Page();
|
|
||||||
}
|
|
||||||
|
|
||||||
await productsApplication.CreateAsync(createProductView);
|
|
||||||
|
|
||||||
return RedirectToPage("Index");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,41 +0,0 @@
|
|||||||
@page
|
|
||||||
@model Server.Pages.Panel.Products.DeleteModel
|
|
||||||
@{
|
|
||||||
var pageTitle =
|
|
||||||
$"{Resources.DataDictionary.CreateOf} {Resources.DataDictionary.Product}";
|
|
||||||
|
|
||||||
ViewData[Constants.ViewDataKeyName.PageTitle] = pageTitle;
|
|
||||||
}
|
|
||||||
<form method="post">
|
|
||||||
|
|
||||||
<section-form>
|
|
||||||
|
|
||||||
<input hidden asp-for="DeleteViewModel.Id" dir="ltr" />
|
|
||||||
|
|
||||||
<fieldset disabled>
|
|
||||||
|
|
||||||
<section-form-header>
|
|
||||||
@(pageTitle)
|
|
||||||
</section-form-header>
|
|
||||||
|
|
||||||
<partial name="PartialViews/_DisplayPageMessages" />
|
|
||||||
|
|
||||||
<ub-full-input asp-for="DeleteViewModel.Name" />
|
|
||||||
|
|
||||||
<ub-full-input asp-for="DeleteViewModel.Description" />
|
|
||||||
|
|
||||||
<ub-full-input asp-for="DeleteViewModel.Price" />
|
|
||||||
|
|
||||||
<ub-full-input asp-for="DeleteViewModel.Quantity" />
|
|
||||||
|
|
||||||
<ub-full-checkbox asp-for="DeleteViewModel.IsActive" />
|
|
||||||
|
|
||||||
</fieldset>
|
|
||||||
|
|
||||||
<section-form-buttons>
|
|
||||||
<button-delete />
|
|
||||||
</section-form-buttons>
|
|
||||||
|
|
||||||
</section-form>
|
|
||||||
|
|
||||||
</form>
|
|
||||||
@@ -1,39 +0,0 @@
|
|||||||
using Application.Aggregates.Products;
|
|
||||||
using Application.Aggregates.Products.ViewModels;
|
|
||||||
using Application.Aggregates.Stores;
|
|
||||||
using Application.Aggregates.Stores.ViewModels;
|
|
||||||
using Microsoft.AspNetCore.Mvc;
|
|
||||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
|
||||||
|
|
||||||
namespace Server.Pages.Panel.Products;
|
|
||||||
|
|
||||||
public class DeleteModel(ProductsApplication productsApplication) : PageModel
|
|
||||||
{
|
|
||||||
[BindProperty]
|
|
||||||
public ProductViewModel DeleteViewModel { get; set; } = new();
|
|
||||||
|
|
||||||
public async Task<IActionResult> OnGetAsync(Guid id)
|
|
||||||
{
|
|
||||||
if (id == Guid.Empty)
|
|
||||||
{
|
|
||||||
return RedirectToPage("Index");
|
|
||||||
}
|
|
||||||
|
|
||||||
DeleteViewModel =
|
|
||||||
await productsApplication.GetAsync(id);
|
|
||||||
|
|
||||||
if (DeleteViewModel == null)
|
|
||||||
{
|
|
||||||
return RedirectToPage("Index");
|
|
||||||
}
|
|
||||||
|
|
||||||
return Page();
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task<IActionResult> OnPostAsync()
|
|
||||||
{
|
|
||||||
await productsApplication.DeleteAsync(DeleteViewModel.Id);
|
|
||||||
|
|
||||||
return RedirectToPage("Index");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,37 +0,0 @@
|
|||||||
@page
|
|
||||||
@model Server.Pages.Panel.Products.IndexModel
|
|
||||||
@{
|
|
||||||
}
|
|
||||||
<div class="my-2 float-end">
|
|
||||||
<a class="btn btn-primary" asp-page="Create">@(Resources.ButtonCaptions.Create)</a>
|
|
||||||
</div>
|
|
||||||
<table class="table table-hover">
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
@(Html.Ub_DisplayStringWithTh(Resources.DataDictionary.Name))
|
|
||||||
@(Html.Ub_DisplayStringWithTh(Resources.DataDictionary.Description))
|
|
||||||
@(Html.Ub_DisplayStringWithTh(Resources.DataDictionary.Price))
|
|
||||||
@(Html.Ub_DisplayStringWithTh(Resources.DataDictionary.Quantity))
|
|
||||||
@(Html.Ub_DisplayStringWithTh(Resources.DataDictionary.IsActive))
|
|
||||||
<th scope="col"></th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
@foreach (var item in Model.product)
|
|
||||||
{
|
|
||||||
<tr>
|
|
||||||
@(Html.Ub_DisplayStringWithTd(item.Name))
|
|
||||||
@(Html.Ub_DisplayStringWithTd(item.Description))
|
|
||||||
@(Html.Ub_DisplayIntegerWithTd(item.Price))
|
|
||||||
@(Html.Ub_DisplayIntegerWithTd(item.Quantity))
|
|
||||||
@(Html.Ub_DisplayBooleanWithTd(item.IsActive))
|
|
||||||
<td>
|
|
||||||
<div class="btn-group" role="group" aria-label="Basic example">
|
|
||||||
<a asp-page="Update" asp-route-Id="@(item.Id)" class="btn btn-warning">@(Resources.ButtonCaptions.Edit)</a>
|
|
||||||
<a asp-page="Delete" asp-route-Id="@(item.Id)" class="btn btn-danger">@(Resources.ButtonCaptions.Delete)</a>
|
|
||||||
</div>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
}
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
using Application.Aggregates.Products;
|
|
||||||
using Application.Aggregates.Products.ViewModels;
|
|
||||||
using Application.Aggregates.Stores;
|
|
||||||
using Application.Aggregates.Stores.ViewModels;
|
|
||||||
using Microsoft.AspNetCore.Mvc;
|
|
||||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
|
||||||
|
|
||||||
namespace Server.Pages.Panel.Products
|
|
||||||
{
|
|
||||||
public class IndexModel(ProductsApplication productsApplication) : PageModel
|
|
||||||
{
|
|
||||||
public List<ProductViewModel> product { get; set; } = new();
|
|
||||||
|
|
||||||
public async Task OnGetAsync()
|
|
||||||
{
|
|
||||||
product = await productsApplication.GetStors();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,42 +0,0 @@
|
|||||||
@page
|
|
||||||
@model Server.Pages.Panel.Products.UpdateModel
|
|
||||||
@{
|
|
||||||
var pageTitle =
|
|
||||||
$"{Resources.DataDictionary.CreateOf} {Resources.DataDictionary.Product}";
|
|
||||||
|
|
||||||
ViewData[Constants.ViewDataKeyName.PageTitle] = pageTitle;
|
|
||||||
}
|
|
||||||
<form method="post">
|
|
||||||
|
|
||||||
<section-form>
|
|
||||||
|
|
||||||
<fieldset>
|
|
||||||
|
|
||||||
<section-form-header>
|
|
||||||
@(pageTitle)
|
|
||||||
</section-form-header>
|
|
||||||
|
|
||||||
<partial name="PartialViews/_DisplayPageMessages" />
|
|
||||||
|
|
||||||
<input hidden asp-for="UpdateViewModel.Id" />
|
|
||||||
|
|
||||||
<ub-full-input asp-for="UpdateViewModel.Name" />
|
|
||||||
|
|
||||||
<ub-full-input asp-for="UpdateViewModel.Description" />
|
|
||||||
|
|
||||||
<ub-full-input asp-for="UpdateViewModel.Price" />
|
|
||||||
|
|
||||||
<ub-full-input asp-for="UpdateViewModel.Quantity" />
|
|
||||||
|
|
||||||
<ub-full-checkbox asp-for="UpdateViewModel.IsActive" />
|
|
||||||
|
|
||||||
</fieldset>
|
|
||||||
|
|
||||||
<section-form-buttons>
|
|
||||||
<button-save />
|
|
||||||
<button-reset />
|
|
||||||
</section-form-buttons>
|
|
||||||
|
|
||||||
</section-form>
|
|
||||||
|
|
||||||
</form>
|
|
||||||
@@ -1,42 +0,0 @@
|
|||||||
using Application.Aggregates.Products;
|
|
||||||
using Application.Aggregates.Products.ViewModels;
|
|
||||||
using Application.Aggregates.Stores;
|
|
||||||
using Application.Aggregates.Stores.ViewModels;
|
|
||||||
using Microsoft.AspNetCore.Mvc;
|
|
||||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
|
||||||
|
|
||||||
namespace Server.Pages.Panel.Products;
|
|
||||||
|
|
||||||
public class UpdateModel(ProductsApplication productsApplication) : PageModel
|
|
||||||
{
|
|
||||||
[BindProperty]
|
|
||||||
public ProductViewModel UpdateViewModel { get; set; }
|
|
||||||
|
|
||||||
public async Task<IActionResult> OnGetAsync(Guid id)
|
|
||||||
{
|
|
||||||
if (id == Guid.Empty)
|
|
||||||
{
|
|
||||||
return RedirectToPage("Index");
|
|
||||||
}
|
|
||||||
|
|
||||||
UpdateViewModel =
|
|
||||||
await productsApplication.GetAsync(id);
|
|
||||||
|
|
||||||
if (UpdateViewModel == null)
|
|
||||||
{
|
|
||||||
return RedirectToPage("Index");
|
|
||||||
}
|
|
||||||
|
|
||||||
return Page();
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task<IActionResult> OnPostAsync()
|
|
||||||
{
|
|
||||||
if (ModelState.IsValid)
|
|
||||||
{
|
|
||||||
await productsApplication.UpdateAsync(UpdateViewModel);
|
|
||||||
}
|
|
||||||
|
|
||||||
return RedirectToPage("Index");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -24,7 +24,7 @@
|
|||||||
@(Html.Ub_DisplayStringWithTd(item.Name))
|
@(Html.Ub_DisplayStringWithTd(item.Name))
|
||||||
@(Html.Ub_DisplayStringWithTd(item.Address))
|
@(Html.Ub_DisplayStringWithTd(item.Address))
|
||||||
@(Html.Ub_DisplayStringWithTd(item.Mobile))
|
@(Html.Ub_DisplayStringWithTd(item.Mobile))
|
||||||
@(Html.Ub_DisplayInteger(item.Score))
|
@(Html.Ub_DisplayIntegerWithTd(item.Score))
|
||||||
@(Html.Ub_DisplayBooleanWithTd(item.IsActive))
|
@(Html.Ub_DisplayBooleanWithTd(item.IsActive))
|
||||||
<td>
|
<td>
|
||||||
<div class="btn-group" role="group" aria-label="Basic example">
|
<div class="btn-group" role="group" aria-label="Basic example">
|
||||||
|
|||||||
@@ -45,7 +45,7 @@
|
|||||||
|
|
||||||
<script src="~/lib/jquery/dist/jquery.min.js"></script>
|
<script src="~/lib/jquery/dist/jquery.min.js"></script>
|
||||||
<script src="~/lib/jquery-validation/dist/jquery.validate.min.js"></script>
|
<script src="~/lib/jquery-validation/dist/jquery.validate.min.js"></script>
|
||||||
<script src="~/lib/jquery-validation-unobtrusive//dist/jquery.validate.unobtrusive.min.js"></script>
|
<script src="~/lib/jquery-validation-unobtrusive/dist/jquery.validate.unobtrusive.min.js"></script>
|
||||||
<script src="~/lib/bootstrap/dist/js/bootstrap.bundle.min.js"></script>
|
<script src="~/lib/bootstrap/dist/js/bootstrap.bundle.min.js"></script>
|
||||||
<script src="~/js/site.js" asp-append-version="true"></script>
|
<script src="~/js/site.js" asp-append-version="true"></script>
|
||||||
|
|
||||||
|
|||||||
@@ -1,12 +1,9 @@
|
|||||||
using Application.Aggregates.Products;
|
|
||||||
using Application.Aggregates.Stores;
|
using Application.Aggregates.Stores;
|
||||||
using Application.Aggregates.Users;
|
using Application.Aggregates.Users;
|
||||||
using Domain.Aggregates.Products.Data;
|
|
||||||
using Domain.Aggregates.Stores.Data;
|
using Domain.Aggregates.Stores.Data;
|
||||||
using Domain.Aggregates.Users.Data;
|
using Domain.Aggregates.Users.Data;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Persistence;
|
using Persistence;
|
||||||
using Persistence.Repositories.Aggregates.Products;
|
|
||||||
using Persistence.Repositories.Aggregates.Stores;
|
using Persistence.Repositories.Aggregates.Stores;
|
||||||
using Persistence.Repositories.Aggregates.Users;
|
using Persistence.Repositories.Aggregates.Users;
|
||||||
using Server.Infrastructure.Extensions.ServiceCollections;
|
using Server.Infrastructure.Extensions.ServiceCollections;
|
||||||
@@ -37,9 +34,6 @@ public class Program
|
|||||||
builder.Services.AddScoped<IStoreRepository, StoreRepository>();
|
builder.Services.AddScoped<IStoreRepository, StoreRepository>();
|
||||||
builder.Services.AddScoped<StoresApplication>();
|
builder.Services.AddScoped<StoresApplication>();
|
||||||
|
|
||||||
builder.Services.AddScoped<IProductRepository, ProductRepository>();
|
|
||||||
builder.Services.AddScoped<ProductsApplication>();
|
|
||||||
|
|
||||||
var app = builder.Build();
|
var app = builder.Build();
|
||||||
|
|
||||||
if (!app.Environment.IsDevelopment())
|
if (!app.Environment.IsDevelopment())
|
||||||
|
|||||||
Reference in New Issue
Block a user