private void AddWBS() { string wbsName = _wbsNameToAdd; string wbsCode = _wbsCodeToAdd; // Check if name is empty if (wbsName == null || wbsName.Replace(" ", String.Empty) == "") { return; } // Check if code is empty if (wbsCode == null || wbsCode.Replace(" ", String.Empty) == "") { return; } // Check if name is already in use among active wbs codes if (WBSViewModels.Any(w => w.Name.Equals(wbsName, StringComparison.CurrentCultureIgnoreCase))) { return; } // Insert into database WBS newWBS = _dbGateway.InsertNewWBS(wbsName, wbsCode, Utilities.ConvertToUnixTime(DateTime.Now)); // Update Collection WBSViewModels.Add(new WBSViewModel(newWBS, _dbGateway)); // Clear user input WBSCodeToAdd = ""; WBSNameToAdd = ""; }
public void DeleteWBS(WBSViewModel wbs) { // Check if currently used by task foreach (TaskViewModel taskVM in TaskViewModels) { if (taskVM.WBSVM == null) { continue; } else if (taskVM.WBSVM.WBSItem.WBSId == wbs.WBSItem.WBSId) { return; } } // Delete task from database _dbGateway.DeleteWBS(wbs.WBSItem); // Remove task from collection WBSViewModels.Remove(wbs); }