|
|
@ -27,10 +27,8 @@ namespace CoviDok.Controllers |
|
|
|
[HttpPost("{id}")] |
|
|
|
public async Task<ActionResult<Case>> PostGetCase(int id, string SessionId) |
|
|
|
{ |
|
|
|
Session s = await Handler.GetSession(SessionId); |
|
|
|
if (s == null) return Unauthorized(); |
|
|
|
|
|
|
|
try { |
|
|
|
Session s = await Handler.GetSession(SessionId); |
|
|
|
return await mgr.GetCase(s, id); |
|
|
|
} |
|
|
|
catch (KeyNotFoundException) |
|
|
@ -48,10 +46,9 @@ namespace CoviDok.Controllers |
|
|
|
[HttpPut("{id}/update")] |
|
|
|
public async Task<IActionResult> PostUpdate(int id, CaseUpdate data) |
|
|
|
{ |
|
|
|
Session s = await Handler.GetSession(data.SessionId); |
|
|
|
if (s == null) return Unauthorized(); |
|
|
|
try |
|
|
|
{ |
|
|
|
Session s = await Handler.GetSession(data.SessionId); |
|
|
|
await mgr.UpdateCase(s, id, data.UpdateMsg, data.Images); |
|
|
|
return Ok(); |
|
|
|
} |
|
|
@ -72,11 +69,9 @@ namespace CoviDok.Controllers |
|
|
|
[HttpPost] |
|
|
|
public async Task<ActionResult<Case>> NewCase(CaseCreate data) |
|
|
|
{ |
|
|
|
Session s = await Handler.GetSession(data.SessionId); |
|
|
|
if (s == null) return Unauthorized(); |
|
|
|
|
|
|
|
try |
|
|
|
{ |
|
|
|
Session s = await Handler.GetSession(data.SessionId); |
|
|
|
Case c = await mgr.CreateCase(s, data.DoctorId, data.ChildId, data.Title, data.StartDate); |
|
|
|
return CreatedAtAction("PostGetCase", new { id = c.Id }, c); |
|
|
|
} |
|
|
@ -89,9 +84,8 @@ namespace CoviDok.Controllers |
|
|
|
[HttpPost("{id}/updates")] |
|
|
|
public async Task<ActionResult<List<Update>>> GetUpdatesForCase(int id, string SessionId) |
|
|
|
{ |
|
|
|
Session s = await Handler.GetSession(SessionId); |
|
|
|
if (s == null) return Unauthorized(); |
|
|
|
try { |
|
|
|
Session s = await Handler.GetSession(SessionId); |
|
|
|
return await mgr.GetUpdatesForCase(s, id); |
|
|
|
} |
|
|
|
catch (UnauthorizedAccessException) |
|
|
@ -107,10 +101,9 @@ namespace CoviDok.Controllers |
|
|
|
[HttpPost("updates/{id}")] |
|
|
|
public async Task<ActionResult<Update>> GetUpdate(int id, string SessionId) |
|
|
|
{ |
|
|
|
Session s = await Handler.GetSession(SessionId); |
|
|
|
if (s == null) return Unauthorized(); |
|
|
|
try |
|
|
|
{ |
|
|
|
Session s = await Handler.GetSession(SessionId); |
|
|
|
return await mgr.GetUpdate(s, id); |
|
|
|
} |
|
|
|
catch (UnauthorizedAccessException) |
|
|
@ -127,10 +120,9 @@ namespace CoviDok.Controllers |
|
|
|
[HttpPost("{id}/close")] |
|
|
|
public async Task<IActionResult> PostClose(int id, string SessionId) |
|
|
|
{ |
|
|
|
Session s = await Handler.GetSession(SessionId); |
|
|
|
if (s == null) return Unauthorized(); |
|
|
|
try |
|
|
|
{ |
|
|
|
Session s = await Handler.GetSession(SessionId); |
|
|
|
await mgr.SetCertified(s, id); |
|
|
|
return Ok(); |
|
|
|
} |
|
|
@ -147,10 +139,9 @@ namespace CoviDok.Controllers |
|
|
|
[HttpPost("{id}/cure")] |
|
|
|
public async Task<IActionResult> PostCured(int id, string SessionId) |
|
|
|
{ |
|
|
|
Session s = await Handler.GetSession(SessionId); |
|
|
|
if (s == null) return Unauthorized(); |
|
|
|
try |
|
|
|
{ |
|
|
|
Session s = await Handler.GetSession(SessionId); |
|
|
|
await mgr.SetCured(s, id); |
|
|
|
return Ok(); |
|
|
|
} |
|
|
@ -168,11 +159,9 @@ namespace CoviDok.Controllers |
|
|
|
[HttpPost("filter")] |
|
|
|
public async Task<ActionResult<List<Case>>> Filter(CaseFilter filters) |
|
|
|
{ |
|
|
|
Session s = await Handler.GetSession(filters.SessionId); |
|
|
|
if (s == null) return Unauthorized(); |
|
|
|
|
|
|
|
try |
|
|
|
{ |
|
|
|
Session s = await Handler.GetSession(filters.SessionId); |
|
|
|
return await mgr.FilterCases(s, filters); |
|
|
|
} |
|
|
|
catch (UnauthorizedAccessException) |
|
|
|