public IActionResult Create() { var model = new NewBillTypeDetails(); model.Type = new BillType(); model.PriceParts = new List <BillPricePart>(); model.PriceParts.Add(new BillPricePart()); return(View(model)); }
public void CreatePost([FromForm] NewBillTypeDetails billData) { _context.BillTypes.Add(billData.Type); foreach (var billPart in billData.PriceParts) { billPart.Type = billData.Type; _context.BillPriceParts.Add(billPart); } _context.SaveChanges(); Redirect("/BillMeasures"); }