public static GroupVM GroupBllToGroupVm(GroupBLL bllGroup)
        {
            GroupInfo gi = new GroupInfo(bllGroup.Title, bllGroup.BackgroundColor, bllGroup.FontColor,
                                         bllGroup.FontName, bllGroup.FontSize, bllGroup.BeginTime, bllGroup.IsExpanded);

            return new GroupVM(bllGroup.ItemID, gi, bllGroup.ResolveTime);
        }
        /// <summary>
        /// This method is used to update details of existing 'Groups'. To change a 
        /// Group's parent, ie. to move a Group from one containing Group to another,
        /// use the methods in the ChecklistElementOrganizer.
        /// </summary>
        public bool UpdateGroup(int id, GroupInfo gInfo, out string errors)
        {
            errors = "";

            Group groupToUpdate = _context.ChecklistElements.OfType<Group>()
                .Where(g => g.ItemID == id).SingleOrDefault();

            if (groupToUpdate != null)
            {
                GroupInfoToGroup(gInfo, groupToUpdate);

                if (ValidateGroup(groupToUpdate, out errors))
                {
                    _context.SaveChanges();
                    return true;
                }
                else
                    return false;
            }
            else
            {
                errors = "No Group with the specified ItemID exists.";
                return false;
            }
        }
        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 GroupBLL(int id, int? parentGroupId, GroupInfo gInfo, DateTime? resolveTime)
     : base(id, parentGroupId, gInfo, resolveTime)
 {
     IsExpanded = gInfo.IsExpanded;
     Items = new List<ChecklistElementBLL>();
 }
 public GroupVM(int id, GroupInfo groupInfo, DateTime? resolveTime, GroupVM parentGroup = null)
     : base(id, groupInfo, resolveTime, parentGroup)
 {
     IsExpanded = groupInfo.IsExpanded;
     CurrentIndex = -1;
 }
        private void GroupInfoToGroup(GroupInfo gi, Group g)
        {
            BLLUtility.ChecklistElementInfoToChecklistElement(gi, g);

            g.IsExpanded = gi.IsExpanded;
        }