public bool AddNewGroup(GroupInfo gInfo, Nullable<int> parentGroupId, out string errors) { errors = ""; if (gInfo == null) { errors += "The provided GroupInfo object is null."; } else { Group groupToAdd = new Group(); GroupInfoToGroup(gInfo, groupToAdd); groupToAdd.ParentGroupID = parentGroupId; if (ValidateGroup(groupToAdd, out errors)) { int newGroupId = HardSettingsManager.GetAndAdvanceNextChecklistElementKey(_context); if (newGroupId != -1) { groupToAdd.ItemID = newGroupId; BLLUtility.AddPositionInfo(_context, groupToAdd, parentGroupId); _context.ChecklistElements.AddObject(groupToAdd); _context.SaveChanges(); } else errors = "The next key information could not be retrieved from the database."; } } return false; }
public static GroupBLL CreateGroupBll(Group dalGroup) { return new GroupBLL(dalGroup.ItemID, dalGroup.ParentGroupID, new GroupInfo(dalGroup.Title, dalGroup.BackgroundColor, dalGroup.FontColor, dalGroup.FontName, dalGroup.FontSize, dalGroup.BeginTime, dalGroup.IsExpanded), dalGroup.ResolveTime); }
private void GroupInfoToGroup(GroupInfo gi, Group g) { BLLUtility.ChecklistElementInfoToChecklistElement(gi, g); g.IsExpanded = gi.IsExpanded; }
private bool ValidateGroup(Group group, out string errors) { errors = ""; string ceValiErrs = null; if (!BLLUtility.ValidateChecklistElement(_context, group, out ceValiErrs)) errors += ceValiErrs; //possible future stuff. if (string.IsNullOrWhiteSpace(errors)) return true; else return false; }
private void FixupParentGroup(Group previousValue) { if (previousValue != null && previousValue.ChecklistElements.Contains(this)) { previousValue.ChecklistElements.Remove(this); } if (ParentGroup != null) { if (!ParentGroup.ChecklistElements.Contains(this)) { ParentGroup.ChecklistElements.Add(this); } if (ParentGroupID != ParentGroup.ItemID) { ParentGroupID = ParentGroup.ItemID; } } else if (!_settingFK) { ParentGroupID = null; } }