Skip to content

Commit

Permalink
Merge pull request #2 from rajguptaH/develop
Browse files Browse the repository at this point in the history
removed some mistakes in services
  • Loading branch information
rajguptaH authored Feb 4, 2023
2 parents 1b982e9 + 7e000de commit 7b01da1
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
4 changes: 2 additions & 2 deletions WebApiExample/WebApiExample/Controllers/StudentController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public IActionResult AddStudent([FromBody] StudentModel studentModel)
return BadRequest(ex.Message);
}
}
[HttpPost("UpdateStudent")]
[HttpPut("UpdateStudent")]
public IActionResult UpdateStudent([FromBody] StudentModel studentModel)
{
try
Expand All @@ -63,7 +63,7 @@ public IActionResult UpdateStudent([FromBody] StudentModel studentModel)
return BadRequest(ex.Message);
}
}
[HttpDelete("Delete/{id}")]
[HttpDelete("Delete/{Id}")]
public IActionResult Delete(int id)
{
try
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,9 @@ public IDbConnection GetConnection
{
{

// var connectionString = "Server=localhost;Database=Maui; User ID=sa;Password=admin;";

try
{

SqlConnection connection = new SqlConnection(_configuration["ConnectionStrings:Prop"]);
return connection;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,16 @@ public bool Delete(int id)

con.Execute(@"update [Student] set
IsDeleted = 1
where Id = @Id", new {id});
where Id = @id", new {id});
return true;
}

public List<StudentModel> Get()
{
using IDbConnection con = _connectionBuilder.GetConnection;

return con.Query<StudentModel>(@"select * From [Student] where IsDeleted = 0").ToList();

}

public StudentModel Get(int id)
Expand All @@ -48,13 +50,15 @@ public int Insert(StudentModel uiPageTypeModel)

public bool Update(StudentModel uiPageTypeModel)
{
using IDbConnection con = _connectionBuilder.GetConnection;
con.Execute(@"update [Student] Set
var query = @"update [Student] Set
Name = @Name,
Class = @Class,
RollNo = @RollNo,
Address = @Address
where Id = @Id", uiPageTypeModel);
where Id = @Id";

using IDbConnection con = _connectionBuilder.GetConnection;
con.Execute(query, uiPageTypeModel);
return true;
}
}
Expand Down

0 comments on commit 7b01da1

Please sign in to comment.