Open fasteddys opened 6 months ago
hello, this is very nice, can you help and point me to code section where the code take user input, I want create code and submit PR, to allow user to directly paste his already created C# Poco or JSON objects from previous application to speed up the typing process
Can you give an example?
sure, below is a small sample of C# model objects from my legacy app, I wanted to paste these models and properties directly inside EASY ABP GUI
or upload them either in C# or JSON, this eliminates a lot of typing.. and then generate the rest of the layers/code
using System;
using System.Collections.Generic;
namespace WarehouseManagement.Models
{
public class Warehouse
{
public int WarehouseId { get; set; }
public string Name { get; set; }
public string Location { get; set; }
// Navigation property
public ICollection<Inventory> Inventories { get; set; }
}
public class Product
{
public int ProductId { get; set; }
public string Name { get; set; }
public string Description { get; set; }
// Navigation property
public ICollection<Inventory> Inventories { get; set; }
}
public class Inventory
{
public int InventoryId { get; set; }
public int WarehouseId { get; set; }
public int ProductId { get; set; }
public int Quantity { get; set; }
// Navigation properties
public Warehouse Warehouse { get; set; }
public Product Product { get; set; }
}
}
I removed the functions to summarize it, but if you want to see the functions as well..
using System;
using System.Collections.Generic;
namespace WarehouseManagement.Models
{
public class Warehouse
{
public int WarehouseId { get; set; }
public string Name { get; set; }
public string Location { get; set; }
public ICollection<Inventory> Inventories { get; set; }
// Constructor
public Warehouse()
{
Inventories = new List<Inventory>();
}
// Add product to warehouse inventory
public void AddProduct(Product product, int quantity)
{
var existingInventory = Inventories.FirstOrDefault(i => i.ProductId == product.ProductId);
if (existingInventory != null)
{
existingInventory.Quantity += quantity;
}
else
{
Inventories.Add(new Inventory { Product = product, Quantity = quantity });
}
}
// Remove product from warehouse inventory
public bool RemoveProduct(Product product, int quantity)
{
var existingInventory = Inventories.FirstOrDefault(i => i.ProductId == product.ProductId);
if (existingInventory != null && existingInventory.Quantity >= quantity)
{
existingInventory.Quantity -= quantity;
return true;
}
return false;
}
}
public class Product
{
public int ProductId { get; set; }
public string Name { get; set; }
public string Description { get; set; }
public ICollection<Inventory> Inventories { get; set; }
// Constructor
public Product()
{
Inventories = new List<Inventory>();
}
}
public class Inventory
{
public int InventoryId { get; set; }
public int WarehouseId { get; set; }
public int ProductId { get; set; }
public int Quantity { get; set; }
public Warehouse Warehouse { get; set; }
public Product Product { get; set; }
}
public class WarehouseManager
{
private List<Warehouse> Warehouses { get; set; }
private List<Product> Products { get; set; }
public WarehouseManager()
{
Warehouses = new List<Warehouse>();
Products = new List<Product>();
}
// Add a warehouse
public void AddWarehouse(Warehouse warehouse)
{
Warehouses.Add(warehouse);
}
// Add a product
public void AddProduct(Product product)
{
Products.Add(product);
}
// Get all warehouses
public IEnumerable<Warehouse> GetAllWarehouses()
{
return Warehouses;
}
// Get all products
public IEnumerable<Product> GetAllProducts()
{
return Products;
}
}
}
JSON models
// Warehouse JSON representation
{
"WarehouseId": 1,
"Name": "Main Warehouse",
"Location": "City A",
"Inventories": [
{
"InventoryId": 1,
"WarehouseId": 1,
"ProductId": 1,
"Quantity": 100
},
{
"InventoryId": 2,
"WarehouseId": 1,
"ProductId": 2,
"Quantity": 50
}
]
}
// Product JSON representation
{
"ProductId": 1,
"Name": "Product A",
"Description": "Description of Product A",
"Inventories": [
{
"InventoryId": 1,
"WarehouseId": 1,
"ProductId": 1,
"Quantity": 100
}
]
}
// Inventory JSON representation
{
"InventoryId": 1,
"WarehouseId": 1,
"ProductId": 1,
"Quantity": 100,
"Warehouse": {
"WarehouseId": 1,
"Name": "Main Warehouse",
"Location": "City A"
},
"Product": {
"ProductId": 1,
"Name": "Product A",
"Description": "Description of Product A"
}
}
You can migrate an existing model to a new project and then use the generator operation by easyabp. A simple JSON object cannot accurately express the specific type of a field
thanks for that, I was saying JSON or C# models.
When I followed this like, here https://github.com/EasyAbp/AbpHelper.GUI/blob/master/docs/AbpHelper-CLI/Generate-CRUD-Code/Usage.md
Load Entity
Button or Load Entity Directory Button, Sorry, in the docs it does not show how to point or Load into Visual Studio 2022 to models namespace, the generator to the existing C# models, can you please add a link/ show some pictures which button to load my entity, in the main docs, on how to point the generator to my models and generate the layers
But this is a C# model
public class Inventory
{
public int InventoryId { get; set; }
public int WarehouseId { get; set; }
public int ProductId { get; set; }
public int Quantity { get; set; }
public Warehouse Warehouse { get; set; }
public Product Product { get; set; }
}
public class WarehouseManager
{
private List<Warehouse> Warehouses { get; set; }
private List<Product> Products { get; set; }
public WarehouseManager()
{
Warehouses = new List<Warehouse>();
Products = new List<Product>();
}
// Add a warehouse
public void AddWarehouse(Warehouse warehouse)
{
Warehouses.Add(warehouse);
}
// Add a product
public void AddProduct(Product product)
{
Products.Add(product);
}
// Get all warehouses
public IEnumerable<Warehouse> GetAllWarehouses()
{
return Warehouses;
}
// Get all products
public IEnumerable<Product> GetAllProducts()
{
return Products;
}
}
Please refer to the official entity model documentation For example
public class Inventory : Entity
{
public int InventoryId { get; set; }
public int WarehouseId { get; set; }
public int ProductId { get; set; }
...
other code
...
public override object[] GetKeys()
{
return new object[] { InventoryId, WarehouseId, ProductId};
}
}
You can refer to the specific source code of the generator
Thanks @blackWins , my confusion is which button
Loads my C# entity into your tool AbpHelper.GUI?
I dont see a button to load entities?
Hello thanks for this explaining I am facing similar issue, where I am trying to port and move everything using EasyABP for the a) first time (do we open old orchard solution and load?) and then keeping the b) updated inside the new MyEasyAbpNewsSite
so in my situation, there are two steps I am struggling to make smooth and easy. I think others will benefit if we make this smooth, in the help guide it shows how to do it in CLI. Issue is that, since the entities are in the old solution, when I clicked open solution in the old solution it hung. Maybe I misunderstood here on which solution to open. For the first time, should developers create a new temp folder with all the entities copied and load them from the there, or maybe paste the code directly in the AbpGUI screen or tab?
Suggestion: Can you please make it smoother to easily copy the entities into EasyABP
PoCo models/ C# entities
to ABP with handling for (nullable types, Id/Key fields, ref fields).cs
files
Hello, this i s great but moving to EasyAbp from previous legacy app can be made 10x faster.
I have 30 models, can you allow developers to paste the C# models or Json objects in the helper GUI and generate the items needed via Helper.