Skip to content

Commit 456cff2

Browse files
🔨 Implement Author endpoints
1 parent 8b4e997 commit 456cff2

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
using EntityFrameworkCore.DataEncryption.Sample.Context;
2+
using EntityFrameworkCore.DataEncryption.Sample.Entities;
3+
using Microsoft.AspNetCore.Mvc;
4+
5+
namespace EntityFrameworkCore.DataEncryption.Sample.Controllers;
6+
7+
[ApiController]
8+
[Route("[controller]")]
9+
public class AuthorController : ControllerBase
10+
{
11+
private readonly SampleDbContext _context;
12+
13+
public AuthorController(SampleDbContext context)
14+
{
15+
_context = context;
16+
}
17+
18+
[HttpGet(Name = "Filter")]
19+
public Task<IActionResult> FilterAsync([FromQuery]string phone)
20+
{
21+
return Task.FromResult<IActionResult>(Ok(_context.Authors.Where(a=>a.Phone == phone).ToList()));
22+
}
23+
24+
[HttpPost(Name = "Insert")]
25+
public async Task<IActionResult> InsertAsync([FromBody]Author author)
26+
{
27+
await _context.Authors.AddAsync(author);
28+
await _context.SaveChangesAsync();
29+
return NoContent();
30+
}
31+
}

0 commit comments

Comments
 (0)