public static BillDisplay BillModelToBillDisplay(BillModel bill) { return(new BillDisplay() { Id = bill.Id, Customer_ = LazyWorker <Customer> .Get(bill.CustomerId != null?bill.CustomerId.Value : 0), Employee_ = LazyWorker <Employee> .Get(bill.EmployeeId != null?bill.EmployeeId.Value : 0), CreatingDay = bill.CreatingDay }); }
private void NewBillButton_Click(object sender, EventArgs e) { BillModel bill = new BillModel() { CustomerId = (CustomerComboBox.SelectedIndex == 0 ? null : (int?)CustomerComboBox.SelectedIndex), EmployeeId = (EmployeeComboBox.SelectedIndex == 0 ? null : (int?)EmployeeComboBox.SelectedIndex), CreatingDay = DateTime.Today.Date }; bill.Id = LazyWorker <BillModel> .Insert(bill); SetCurrentBill(LessLazyWorker.BillModelToBillDisplay(bill)); }