-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathNoteController.cs
More file actions
61 lines (56 loc) · 1.91 KB
/
Copy pathNoteController.cs
File metadata and controls
61 lines (56 loc) · 1.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
using BervProject.WebApi.Boilerplate.Entities;
using BervProject.WebApi.Boilerplate.Services;
using Microsoft.AspNetCore.Mvc;
using System.Threading.Tasks;
using BervProject.WebApi.Boilerplate.Services.Azure;
using Microsoft.AspNetCore.Http;
namespace BervProject.WebApi.Boilerplate.Controllers
{
[ApiController]
[Route("api/v{version:apiVersion}/[controller]")]
[ApiVersion("1.0")]
public class NoteController : ControllerBase
{
private readonly IAzureTableStorageService<Note> _noteTable;
public NoteController(IAzureTableStorageService<Note> noteTable)
{
_noteTable = noteTable;
}
/// <summary>
/// Create Azure Table Storage
/// </summary>
/// <returns></returns>
[HttpPost("createTable")]
[ProducesResponseType(typeof(bool), StatusCodes.Status200OK)]
public async Task<IActionResult> CreateTable()
{
await _noteTable.CreateTableAsync();
return Ok(true);
}
/// <summary>
/// Upsert Note
/// </summary>
/// <param name="note"></param>
/// <returns></returns>
[HttpPost("upsert")]
[ProducesResponseType(typeof(bool), StatusCodes.Status200OK)]
public async Task<IActionResult> UpsertNote([FromBody] Note note)
{
await _noteTable.UpsertAsync(note);
return Ok(true);
}
/// <summary>
/// Get Note
/// </summary>
/// <param name="partitionKey"></param>
/// <param name="rowKey"></param>
/// <returns></returns>
[HttpGet("get")]
[ProducesResponseType(typeof(Note), StatusCodes.Status200OK)]
public async Task<IActionResult> Get([FromQuery] string partitionKey, [FromQuery] string rowKey)
{
var result = await _noteTable.GetAsync(partitionKey, rowKey);
return Ok(result);
}
}
}