예제 #1
0
        public string CreatePerson(string name, string email)
        {
            var nameIsNullOrEmpty  = Assert2.IsNullOrEmpty(name, "Name is null");
            var emailIsNullOrEmpty = Assert2.IsNullOrEmpty(email, "Email is null");
            var person             = Person.Factory.Create(name, email)
                                     .ToResult("Error occorred ");
            var combine = Result.Combine(nameIsNullOrEmpty, emailIsNullOrEmpty, person);

            return(combine
                   .OnSuccess(() => person.Value.Valid())
                   .OnSuccess(() => _personRepository.Save(person.Value)
                              .Cath(() => _personRepository.Rollback()))
                   .Finally(CreateLog)
                   .Finally(CreateResult));
        }