Esempio n. 1
0
        public IHttpActionResult Post(string userId, string otherUserId)
        {
            var userRes = UserReader.Lookup(userId).SelectError(
                error => error.Accept(UserLookupError.Switch(
                                          onInvalidId: "Invalid user ID.",
                                          onNotFound:  "User not found.")));
            var otherUserRes = UserReader.Lookup(otherUserId).SelectError(
                error => error.Accept(UserLookupError.Switch(
                                          onInvalidId: "Invalid ID for other user.",
                                          onNotFound:  "Other user not found.")));

            var connect =
                from user in userRes
                from otherUser in otherUserRes
                select Connect(user, otherUser);

            return(connect.SelectBoth(Ok, BadRequest).Bifold());
        }