public async Task <IActionResult> CreateRestaurant([Bind("Name")] Restaurant entity) { var checkIfExists = from selectRestaurant in RestaurantDomain.GetRestaurant(entity.Name) select selectRestaurant; var result = await interpreter.Interpret(checkIfExists, Unit.Default); return(await result.MatchAsync <IActionResult>( async (exists) => { return BadRequest(); }, async (inexistent) => { var expr = from createEntity in RestaurantDomain.CreateAndPersistRestaurant(entity) let entityC = (createEntity as RestaurantCreated)?.RestaurantAgg select createEntity; var result = await interpreter.Interpret(expr, Unit.Default); return await result.MatchAsync <IActionResult>( async(created) => { return (IActionResult)Ok(created.RestaurantAgg.Restaurant); }, async(notCreated) => { return BadRequest(); }); } )); }