public async Task <ActionResult> Query([FromQuery] BlueprintQueryParameters queryParameters) { if (queryParameters == null) { return(this.Problem(ProblemFactory.BadParameters())); } var blueprintQuery = new BlueprintsQuery { MaxProductionEfford = queryParameters.MaxProductionEfford, NameContains = queryParameters.ModelName }; var result = await CommandHandler.Query(blueprintQuery); return(result.Match( success => { var resultHto = Ok(new BlueprintQueryResultHto(success.Result, queryParameters)); return resultHto; }, notReachable => this.Problem(ProblemFactory.ServiceUnavailable()), invalidQuery => this.Problem(ProblemFactory.BadParameters()), error => this.Problem(ProblemFactory.Exception(error.Exception)) )); }
public async Task <ActionResult> GetProductionLines() { var getAllResult = await CommandHandler.GetAllProductionLines(); return(getAllResult.Match( success => Ok(new ProductionHto(success.Result)), notReachable => this.Problem(ProblemFactory.ServiceUnavailable()), error => this.Problem(ProblemFactory.Exception(error.Exception)))); }
public ActionResult NewQuery(BlueprintQueryParameters queryParameters) { if (queryParameters == null) { return(this.Problem(ProblemFactory.BadParameters())); } var canQueryResult = CommandHandler.CanQueryBlueprints(); return(canQueryResult.Match( // Will create a Location header with a URI to the result. available => this.CreatedQuery(typeof(BlueprintQueryResultHto), queryParameters), notAvailable => this.Problem(ProblemFactory.OperationNotAvailable()), notReachable => this.Problem(ProblemFactory.ServiceUnavailable()), error => this.Problem(ProblemFactory.Exception(error.Exception)) )); }