Hi, Good morning all, I am new to asp.net core 6.0 and i have this issues...
I have this model Called OrderModel, inside it I have order class and orderDetails Class
public class Order
{
[Key]
public int OrderId { get; set; }
[Display(Name = "Customer Name")]
[Required(ErrorMessage = "Please Select Customer Name")]
public String CustomerName { get; set; }
public ICollection? OrderDetails { get; set; }
}
public class OrderDetail
{
[Key]
public int DetailId { get; set; }
public int OrderId { get; set; }
[Display(Name = "Service")]
public string ServiceName { get; set; }
[Display(Name = "Quantity")]
public int Quantity { get; set; }
[Display(Name ="Unit Price")]
public float UnitPrice { get; set; }
[ForeignKey("OrderId")]
public Order? Order { get; set; }
}
//On my view, I want to be able to display the Order Class as a form and the OrderDetails as an editable table with 10 rows ..
public IActionResult Customer_Order()
{
// I want to be able to display upto 10 rows..
List od = new List();
od.Add(new OrderDetail { DetailId = 0, Discount = 0, Quantity = 0, ServiceName = "Select Service", UnitPrice = 0, TotalAmount = 0 });
od.Add(new OrderDetail { DetailId = 0, Discount = 0, Quantity = 0, ServiceName = "Select Service", UnitPrice = 0, TotalAmount = 0 });
return View(od);
}
On Post, I want to be able to save the data to both order table and orderdetails table
@model Customer.Models.Order