public async Task <IActionResult> Create(BillForCreateDto billForCreateDto) { var billToCreate = new Bill { StaffId = billForCreateDto.StaffId, MemberId = billForCreateDto.MemberId, CreatedDate = billForCreateDto.CreatedDate, Value = billForCreateDto.Value }; var createdBill = await _repo.Create(billToCreate); var bills = _context.Bills.ToList(); var id = bills[bills.Count - 1].Id; foreach (var detail in billForCreateDto.BillDetails) { var detailToCreate = new BillDetail { BillId = id, ProductDetailId = detail.ProductDetailId, Amount = detail.Amount }; var createBillDetail = await _repo.CreateBillDetail(detailToCreate); } return(StatusCode(201)); }