public void ChangeContact(string userId, ContactData contactData) { Stage.ActorOf <IUser>(_addressFactory.From(userId)) .AndThenTo(user => user.WithContact(new Contact(contactData.EmailAddress, contactData.TelephoneNumber))) .OtherwiseConsume(noUser => Completes.With(Response.Of(ResponseStatus.NotFound, UserLocation(userId)))) .AndThenConsume(userState => Response.Of(ResponseStatus.Ok, JsonSerialization.Serialized(UserData.From(userState)))); }
public void ChangeName(string userId, NameData nameData) { Stage.ActorOf <IUser>(_addressFactory.From(userId)) .AndThenTo(user => user.WithName(new Name(nameData.Given, nameData.Family))) .OtherwiseConsume(noUser => Completes.With(Response.Of(ResponseStatus.NotFound, UserLocation(userId)))) .AndThenConsume(userState => { _repository.Save(userState); Completes.With(Response.Of(ResponseStatus.Ok, JsonSerialization.Serialized(UserData.From(userState)))); }); }