public IActionResult AddNewPayment(AddPaymentTypeDto newPaymentType) { if (_repo.AddNewPaymentType(newPaymentType)) { return(Created($"paymentType/{newPaymentType.Type}", newPaymentType)); } else { return(BadRequest()); } }
public bool AddNewPaymentType(AddPaymentTypeDto newPaymentType) { using (var db = new SqlConnection(_connectionString)) { var sql = @"INSERT INTO [PaymentType] ([UserId], [AccountNumber], [Type]) VALUES (@userId, @accountNumber, @type)"; return(db.Execute(sql, newPaymentType) == 1); } }