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 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172
| using System.Net.NetworkInformation; using System.Threading.Tasks; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; using Note.Application.DTOs; using Note.Application.Services; using Note.Shared; using Notes.API; using Swashbuckle.AspNetCore.Annotations; using Swashbuckle.AspNetCore.Filters; using static System.Net.WebRequestMethods;
namespace Notes.API.Controllers { [ApiController] [Route("api/[controller]")] public class NoteController : ControllerBase { private readonly INoteService _noteService;
public NoteController(INoteService noteService) { _noteService = noteService; }
[HttpGet("{companyKey}/{applicationKey}/{applicationSubKey}")] [SwaggerResponse( StatusCodes.Status200OK, "HTTP 200 means a model is being returned. Check the WasSuccessfulTrue to determine if it worked properly", typeof(IResult<List<NoteDto>>))] [SwaggerResponseExample( StatusCodes.Status200OK, typeof(NoteControllerSwashbuckleExamples.NoteGetAllNotesAsync))] public async Task<IActionResult> GetNotes( string companyKey, string applicationKey, string applicationSubKey) { var result = await _noteService.GetAllNotesAsync(companyKey, applicationKey, applicationSubKey); return Ok(result); }
[HttpGet("{companyKey}/{id}")] [SwaggerResponse( StatusCodes.Status200OK, "HTTP 200 means a model is being returned. Check the WasSuccessfulTrue to determine if it worked properly", typeof(IResult<NoteDto>))] [SwaggerResponseExample( StatusCodes.Status200OK, typeof(NoteControllerSwashbuckleExamples.NoteGetOneExample))] public async Task<IActionResult> GetNote(string companyKey, long id) { var result = await _noteService.GetNoteById(companyKey, id); return Ok(result); }
[HttpPost] [SwaggerRequestExample( typeof(NoteDto), typeof(NoteControllerSwashbuckleExamples.NotePostExample))] [SwaggerResponse( StatusCodes.Status200OK, "HTTP 200 means a model is being returned. Check the WasSuccessfulTrue to determine if it worked properly", typeof(IResult<NoteDto>))] [SwaggerResponseExample( StatusCodes.Status200OK, typeof(NoteControllerSwashbuckleExamples.NotePostResultsExampleSuccess))] [SwaggerResponse( StatusCodes.Status400BadRequest, "If your Request Body is incorrect, then you'll get 400 error. Look at the errors collection to see the problems.", typeof(IResult<NoteDto>))] [SwaggerResponseExample( StatusCodes.Status400BadRequest, typeof(NoteControllerSwashbuckleExamples.NotePostResultsExampleError400))] public async Task<IActionResult> CreateNote([FromBody] NoteDto noteDto) { var result = await _noteService.CreateNote(noteDto); return Ok(result); }
[HttpPut("{id}")] [SwaggerResponse( StatusCodes.Status200OK, type: typeof(BaseResult<bool>))] [SwaggerRequestExample( typeof(NoteDto), typeof(NoteControllerSwashbuckleExamples.NotePutExample))] [SwaggerResponseExample(StatusCodes.Status200OK, typeof(NoteControllerSwashbuckleExamples.NotePostResultsExampleSuccess))] public async Task<IActionResult> UpdateNote( long id, [FromBody] NoteDto noteDto) { noteDto.Id = id; var result = await _noteService.UpdateNote(noteDto); return Ok(result); }
[HttpDelete("{companyKey}/{id}")] [SwaggerResponse( StatusCodes.Status200OK, "HTTP 200 means a model is being returned. Check the WasSuccessfulTrue to determine if it worked properly", typeof(IResult<NoteDto>))] [SwaggerResponseExample( StatusCodes.Status200OK, typeof(NoteControllerSwashbuckleExamples.NoteDeleteResultsExampleSuccess))] public async Task<IActionResult> DeleteNote(string companyKey, long id) { var result = await _noteService.DeleteNote(companyKey, id); return Ok(result); } } }
|