public async Task <Object> Post(dynamic model) { InvoiceModel c = JsonConvert.DeserializeObject <InvoiceModel>(model.ToString()); InvoiceModel reciept = _invoiceServices.Calculate(c); invoices.Add(reciept); List <InvoiceModel> list = invoices; using (StreamWriter writer = new StreamWriter($"{reciept.Id}_invoice.txt")) { writer.WriteLine($"\t INVOICE #{reciept.Id} "); writer.WriteLine(); writer.WriteLine($"Bonus Point = {reciept.BonusPoints}. "); writer.WriteLine(); writer.WriteLine($@"\t---------Products Rented---------"); writer.WriteLine(); foreach (InventoryModel product in reciept.Inventories) { writer.WriteLine($@"{product.Name} {product.RentDays} days ${product.Cost}.00 "); } writer.WriteLine(); writer.WriteLine(); writer.WriteLine($"\t Total \t : \t${reciept.TotalPrice}.00"); } return(new { reciept.Id, reciept.BonusPoints, reciept.TotalPrice, reciept.PurchaseDate, reciept.UserId, reciept.Inventories }); }