public string Post([FromBody] List <string> value) { try { PrintJobParser parser = new PrintJobParser(); PrintJob job = parser.Parse(value); PrintCostCalculator calculator = new PrintCostCalculator(); return(calculator.Calculate(job)); } catch (PrintJobException) { return("Parsing error! Please provide valid input"); } catch (Exception) { return("An unknown error has occurred"); } }
public async Task <int> GetPrintCost(int photoId) { if (photoId == 0) { throw new HttpException(HttpStatusCode.BadRequest, "Please provide a valid photoId."); } var print = new PhotoPrint { PhotoId = photoId }; var costCalculator = new PrintCostCalculator(print); try { return(await costCalculator.GetCost()); } catch (NotFoundException e) { throw new HttpException(HttpStatusCode.NotFound, e.Message); } }