public void SaveFixedCostAllocation() { if (SelectedFixedCostAllocation.FixedCostAllocationId > 0) { FixedCostAllocations.Update(SelectedFixedCostAllocation); foreach (FixedCostAllocationDetail item in SelectedFixedCostAllocation.FixedCostAllocationDetails) { if (item.RefFixedCostAllocationId == 0) { item.RefFixedCostAllocationId = SelectedFixedCostAllocation.FixedCostAllocationId; FixedCostAllocationDetails.Insert(item); } else { FixedCostAllocationDetails.Update(item); } } } else { int id = FixedCostAllocations.Insert(SelectedFixedCostAllocation); foreach (FixedCostAllocationDetail item in SelectedFixedCostAllocation.FixedCostAllocationDetails) { item.RefFixedCostAllocationId = id; FixedCostAllocationDetails.Insert(item); } } }
public void DeleteFixedCostAllocationDetail() { try { FixedCostAllocationDetail itemToRemove = SelectedFixedCostAllocation?.FixedCostAllocationDetails.Single(x => x.CostCenter == SelectedFixedCostAllocationDetail.CostCenter); SelectedFixedCostAllocation?.FixedCostAllocationDetails.Remove(itemToRemove); if (itemToRemove.FixedCostAllocationDetailId != 0) { FixedCostAllocationDetails.Delete(itemToRemove.FixedCostAllocationDetailId); } } catch (Exception) { // TODO Error Message } }
public void SaveFixedCostAllocationDetail() { if (DoesCostCenterAlreadyExist(SelectedCostCenter.CostCenterId)) { Messenger.Default.Send(new OpenDialogWindowMessage("Fehler", "Kostenstelle ist bereits enhalten.", MessageBoxImage.Asterisk)); return; } SelectedFixedCostAllocationDetail.CostCenter = SelectedCostCenter; SelectedFixedCostAllocationDetail.RefCostCenterId = SelectedCostCenter.CostCenterId; SelectedFixedCostAllocationDetail.CostCenter.CostCenterCategory = SelectedCostCenterCategory; SelectedFixedCostAllocationDetail.Shares = Shares; if (SelectedFixedCostAllocationDetail.FixedCostAllocationDetailId > 0) { FixedCostAllocationDetails.Update(SelectedFixedCostAllocationDetail); } }