ASP.NET Core 5 and React by Carl Rippon
Author:Carl Rippon
Language: eng
Format: epub
Publisher: Packt Publishing Pvt Ltd
Published: 2021-01-06T00:00:00+00:00
Creating a repository method to change a question
Let's create the PutQuestion method in DataRepository.cs to change a question. This is very similar to the PostQuestion method we have just implemented:
public QuestionGetSingleResponse PutQuestion(int questionId, QuestionPutRequest question)
{
using (var connection = new SqlConnection(_connectionString))
{
connection.Open();
connection.Execute(
@"EXEC dbo.Question_Put
@QuestionId = @QuestionId, @Title = @Title,
@Content = @Content",
new { QuestionId = questionId, question.Title,
question.Content }
);
return GetQuestion(questionId);
}
}
Notice that we are using the Dapper Execute method because we are simply executing a stored procedure and not returning anything.
We've created the SQL parameters from a model class called QuestionPutRequest and the questionId parameters that were passed into the method. Let's create the QuestionPutRequest class in the models folder:
public class QuestionPutRequest
{
public string Title { get; set; }
public string Content { get; set; }
}
That's another method implemented.
Download
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
Hello! Python by Anthony Briggs(9926)
The Mikado Method by Ola Ellnestam Daniel Brolund(9786)
Dependency Injection in .NET by Mark Seemann(9348)
Sass and Compass in Action by Wynn Netherland Nathan Weizenbaum Chris Eppstein Brandon Mathis(7789)
The Well-Grounded Java Developer by Benjamin J. Evans Martijn Verburg(7566)
Svelte with Test-Driven Development by Daniel Irvine(7247)
Test-Driven Development with PHP 8 by Rainier Sarabia(6982)
Layered Design for Ruby on Rails Applications by Dementyev Vladimir;(6842)
Secrets of the JavaScript Ninja by John Resig & Bear Bibeault(6541)
Secrets of the JavaScript Ninja by John Resig Bear Bibeault(6423)
Web Development with Django by Ben Shaw Saurabh Badhwar(6306)
React Application Architecture for Production by Alan Alickovic(6026)
Jquery UI in Action : Master the concepts Of Jquery UI: A Step By Step Approach by ANMOL GOYAL(5814)
Kotlin in Action by Dmitry Jemerov(5073)
Audition by Ryu Murakami(4592)
Software Architecture for Web Developers by Mihaela Roxana Ghidersa(4495)
Accelerating Server-Side Development with Fastify by Manuel Spigolon Maksim Sinik & Matteo Collina(4346)
Hands-On Full-Stack Web Development with GraphQL and React by Sebastian Grebe(4323)
Solidity Programming Essentials by Ritesh Modi(4051)
