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(WBS wbs) { string sql = "UPDATE WBS SET DeletedDateTime = @DeletedDateTime WHERE WBSId = @WBSId"; long deletedDateTime = Utilities.ConvertToUnixTime(DateTime.Now); _DBConnection.Execute(sql, new { DeletedDateTime = deletedDateTime, WBSId = wbs.WBSId }); }
public void UpdateWBS(WBS wbs) { string sql = "UPDATE WBS SET Name = @Name, Code = @Code WHERE WBSId = @WBSId"; _DBConnection.Execute(sql, new { Name = wbs.Name, Code = wbs.Code, WBSId = wbs.WBSId }); }
public WBSViewModel(WBS wbs, DatabaseGateway dbGateway) { WBSItem = wbs; _dbGateway = dbGateway; }