Esempio n. 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);
        }
Esempio n. 2
0
        public Result EditContact(Contact contact)
        {
            var result = new Result();

            var validationResult = ValidateContact(contact);

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

            dataAccess.EditContact(contact);

            return(result);
        }