private DelpinCore.Lease GetLeaseFromForm() { bool active = false; if (leaseStatus.SelectedText != "Slettet") { active = true; } DelpinCore.Lease lease = new DelpinCore.Lease(debtorIDTextBox.Text, Utility.BranchID, active); lease.SetContactDetails(contactFirstName.Text, contactLastName.Text, contactPhone.Text); foreach (DataGridViewRow row in leaseOrders.Rows) { if (row.Cells["ResurseID"].Value == null) { continue; } int resouceID = Convert.ToInt32(row.Cells["ResurseID"].Value.ToString()); DateTime deliveryDate = Convert.ToDateTime(row.Cells["Leveringsdato"].Value.ToString()); DateTime returnDate = Convert.ToDateTime(row.Cells["Slutdato"].Value.ToString()); decimal price = Convert.ToDecimal(row.Cells["Dagspris"].Value.ToString()); decimal deliveryPrice = Convert.ToDecimal(row.Cells["Levering"].Value.ToString()); string deliveryAddrress = row.Cells["Gade"].Value.ToString(); int deliveryPostCode = 0; try { deliveryPostCode = Convert.ToInt32(row.Cells["Postkode"].Value.ToString()); } catch { } string deliveryCity = row.Cells["By"].Value.ToString(); LeaseOrder leaseOrder = new LeaseOrder(deliveryDate, returnDate, price, resouceID); leaseOrder.SetDeliveryAddress(deliveryAddrress, deliveryPostCode, deliveryCity, deliveryPrice); lease.SetStatus("Åben"); lease.AddLeaseOrder(leaseOrder); } return(lease); }
//LeaseOrder public async Task AddLeaseOrder(LeaseOrder entity) => await _dbContext.Leases.AddAsync(entity);