Exemple #1
0
        // To add a transaction
        public async Task <HttpResponseMessage> PostAsync(Transaction transaction)
        {
            List <Customer> customers = await sqlDbHelper.GetCustomers();

            // checks if that customer exists in the table
            if (customers.Find(a => a.CardNumber == transaction.CardNumber) == null)
            {
                // if the customer does not exist, then no transaction could be made
                return(Request.CreateResponse(HttpStatusCode.NotFound));
            }
            else
            {
                // if a customer exists a transaction will be created
                await sqlDbHelper.AddTransaction(transaction);

                return(Request.CreateResponse(HttpStatusCode.OK, "Created!"));
            }
        }