public Result <bool> UpdatePhone(int id, GroupPhone groupPhone, string number)
        {
            var phone = PhoneInternal.FirstOrDefault(g => g.Id == id);

            if (phone != null)
            {
                var updateResult = phone.Update(groupPhone, number);
                if (!updateResult.Succeeded)
                {
                    return(Result <bool> .Fail(updateResult.Errors));
                }
                return(Result <bool> .Success(true));
            }
            return(Result <bool> .Fail("Phone not found"));
        }
        public Result <bool> AddPhone(GroupPhone groupPhone, string number)
        {
            var errors = new List <string>();

            if (Phones.Any(phone => phone.Number.Equals(number, StringComparison.OrdinalIgnoreCase)))
            {
                errors.Add("This number already exists");
            }

            if (errors.Any())
            {
                return(Result <bool> .Fail(errors));
            }

            var result = Phone.Create(groupPhone, number);

            PhoneInternal.Add(result.Value);
            return(Result <bool> .Success(true));
        }
        public Result <bool> RemovePhone(Phone phoneToDelete)
        {
            var errors = new List <string>();

            if (phoneToDelete is null)
            {
                errors.Add(nameof(phoneToDelete));
            }
            if (Phones.All(phone => !phone.Number.Equals(phoneToDelete.Number, StringComparison.OrdinalIgnoreCase)))
            {
                errors.Add("Not exists");
            }

            if (errors.Any())
            {
                return(Result <bool> .Fail(errors));
            }

            PhoneInternal.Remove(phoneToDelete);
            return(Result <bool> .Success(true));
        }
 public Result <bool> AddPhone(Phone phone)
 {
     PhoneInternal.Add(phone);
     return(Result <bool> .Success(true));
 }