public Customer SaveCustomer(Customer newCustomer) { //var dbConnectionString = ConfigurationManager.ConnectionStrings["LocalDbConnection"].ConnectionString; var dbConnectionString = ConfigurationManager.ConnectionStrings["AzureDbConnection"].ConnectionString; using (var dbConnection = new SqlConnection(dbConnectionString)) { dbConnection.Open(); var parms = new DynamicParameters(); parms.Add("@FirstName", newCustomer.FirstName, DbType.String, ParameterDirection.Input); parms.Add("@LastName", newCustomer.LastName, DbType.String, ParameterDirection.Input); parms.Add("@Email", newCustomer.Email, DbType.String, ParameterDirection.Input); parms.Add("@Phone", newCustomer.Phone, DbType.String, ParameterDirection.Input); var customers = dbConnection.Query<Customer>("[dbo].[SaveCustomer]", parms, null, false, null, CommandType.StoredProcedure); newCustomer = customers.ToList().FirstOrDefault(); } return newCustomer; }
public Customer Post(Customer newCustomer) { var customerData = new CustomerStore(); return customerData.SaveCustomer(newCustomer); }