module Workflows.Commands
open Commands
open Events
type private LinksWorkflow = LinkCommand -> LinksEvent list
type private TopicsWorkflow = TopicsCommand -> TopicsEvent list
let handleLinks : LinksWorkflow = fun command -> command |> function
| LinkCommand.Feature linkId ->
linkId |> Try.featureLink
|> ResultOf.Link.Feature
|> Handle.Registration.result
| LinkCommand.Unfeature linkId ->
linkId |> Try.unfeatureLink
|> ResultOf.Link.Feature
|> Handle.Registration.result
let handleTopics : TopicsWorkflow = fun command -> command |> function
TopicsCommand.Feature topicIds ->
topicIds |> Try.featureTopics
|> ResultOf.Topics.Feature
|> Handle.Topics.result
Portfolio.Logic
module internal Handle
open Events
open Commands
open Commands.ResultOf
module Registration =
type private LinkResult = ResultOf.Link -> LinksEvent list
let linkResult : LinkResult =
fun response ->
response |> function
| Link.Feature result ->
result |> function
| Ok linkId -> [LinkFeatured linkId]
| Error linkId -> [LinkFeaturedFailed linkId]
| Link.Unfeature result ->
result |> function
| Ok linkId -> [LinkUnfeatured linkId]
| Error linkId -> [LinkUnfeaturedFailed linkId]
module Topics =
type private TopicsResult = ResultOf.Topics -> TopicsEvent list
let result : TopicsResult =
fun response ->
response |> function
Topics.Feature result ->
result |> function
| Ok topicIds -> [TopicsFeatured topicIds]
| Error topicIds -> [TopicsFeaturedFailed topicIds]