Exemple #1
0
        public Result DeleteGroup(Group group)
        {
            var canDeleteResult = CanDelete(group);

            if (!canDeleteResult.IsSuccess)
            {
                return(canDeleteResult);
            }

            var result          = new Result();
            var contactsInGroup = dataAccess.GetContacts(group, false);

            if (contactsInGroup.Any())
            {
                var defaultGroup = dataAccess.GetDefaultGroup();
                foreach (var contact in contactsInGroup)
                {
                    contact.Group = defaultGroup;
                    dataAccess.EditContact(contact);
                }
                result.Infos.Add($"{contactsInGroup.Count()} contacts moved to {defaultGroup.Name} group");
            }

            dataAccess.DeleteGroup(group.Id);

            return(result);
        }
 public ValueResult <IEnumerable <Contact> > GetContacts(Group group, bool favourites)
 {
     return(new ValueResult <IEnumerable <Contact> >(dataAccess.GetContacts(group, favourites)));
 }