private Result <bool> CreateGroupAddress(User user, string str) { Result <GroupAddress> group; group = GroupAddress.Create(str); if (group.Succeeded) { if (user.AddGroupAddress(group.Value).Succeeded) { return(Result <bool> .Success(true)); } return(Result <bool> .Success(false)); } return(Result <bool> .Success(false)); }
public async Task <Result <bool> > AddGroupAddressAsync(User user, string name) { if (!user.GroupAddresses.Any(g => g.Name == name)) { var newGroupAddress = GroupAddress.Create(name); if (newGroupAddress.Succeeded) { user.AddGroupAddress(newGroupAddress.Value); await db.SaveChangesAsync(); return(Result <bool> .Success(true)); } return(Result <bool> .Fail(newGroupAddress.Errors)); } return(Result <bool> .Fail(new string[] { "Such GroupAddress exists" })); }