From 374c8007de123871e3e3a4bffe6646bf49a8dff1 Mon Sep 17 00:00:00 2001 From: Daniel Gyulai Date: Wed, 4 Nov 2020 13:32:13 +0100 Subject: [PATCH] Make codebase compliant to recently added tests --- CoviDok/Api/GenericResponse.cs | 13 ++++++++++--- CoviDok/Api/Request/CaseFilter.cs | 7 ++++++- CoviDok/Api/Response/FilteredCases.cs | 6 +++++- CoviDok/BLL/Tools.cs | 2 +- CoviDok/Controllers/AuthController.cs | 14 +++++++------- CoviDok/Controllers/CaseController.cs | 9 +++++---- CoviDok/Controllers/DocController.cs | 25 ++++++++----------------- CoviDok/api/Request/AuthRegistration.cs | 4 ++++ CoviDok/data/Case.cs | 7 ++++++- 9 files changed, 52 insertions(+), 35 deletions(-) diff --git a/CoviDok/Api/GenericResponse.cs b/CoviDok/Api/GenericResponse.cs index 4a65b10..ebc1940 100644 --- a/CoviDok/Api/GenericResponse.cs +++ b/CoviDok/Api/GenericResponse.cs @@ -9,12 +9,19 @@ namespace CoviDok.Api { public int Version { get; set; } public Status Status { get; set; } - public Dictionary Body = new Dictionary(); + public Dictionary Body { get; set; } + + public GenericResponse() + { + Body = new Dictionary(); + Version = 1; + Status = Status.Success; + } } public enum Status { - Error, - Success + Success, + Error } } diff --git a/CoviDok/Api/Request/CaseFilter.cs b/CoviDok/Api/Request/CaseFilter.cs index d29c449..e6fb5e7 100644 --- a/CoviDok/Api/Request/CaseFilter.cs +++ b/CoviDok/Api/Request/CaseFilter.cs @@ -9,6 +9,11 @@ namespace CoviDok.Api.Request public class CaseFilter { public string SessionID { get; set; } - public Dictionary Filters = new Dictionary(); + public Dictionary Filters { get; set; } + + public CaseFilter() + { + Filters = new Dictionary(); + } } } diff --git a/CoviDok/Api/Response/FilteredCases.cs b/CoviDok/Api/Response/FilteredCases.cs index 32c3e82..aed2e63 100644 --- a/CoviDok/Api/Response/FilteredCases.cs +++ b/CoviDok/Api/Response/FilteredCases.cs @@ -8,6 +8,10 @@ namespace CoviDok.Api.Response { public class FilteredCases { - public ICollection Cases = new List(); + public ICollection Cases { get; set; } + public FilteredCases() + { + Cases = new List(); + } } } diff --git a/CoviDok/BLL/Tools.cs b/CoviDok/BLL/Tools.cs index 0c085d8..706f211 100644 --- a/CoviDok/BLL/Tools.cs +++ b/CoviDok/BLL/Tools.cs @@ -70,7 +70,7 @@ namespace CoviDok.BLL Sender = RandomString(13), Id = RandomString(8) }; - c.updates.Add(u); + c.Updates.Add(u); } return c; } diff --git a/CoviDok/Controllers/AuthController.cs b/CoviDok/Controllers/AuthController.cs index 776e6ad..38b4e61 100644 --- a/CoviDok/Controllers/AuthController.cs +++ b/CoviDok/Controllers/AuthController.cs @@ -35,6 +35,7 @@ namespace CoviDok.Controllers [HttpPost("register")] public async Task> PostRegister(AuthRegistration authRegistration) { + // System.Diagnostics.Debug.WriteLine(authRegistration.ToString()); GenericResponse genericResponse = new GenericResponse(); if (authRegistration.Email == "a") { @@ -43,11 +44,7 @@ namespace CoviDok.Controllers } else if (authRegistration.Password == "1") { genericResponse.Status = Status.Error; - genericResponse.Body["reason"] = "Password dows not meet complexity requirements!"; - } - else - { - genericResponse.Status = Status.Success; + genericResponse.Body["reason"] = "Password does not meet complexity requirements!"; } return genericResponse; @@ -58,14 +55,17 @@ namespace CoviDok.Controllers public async Task> PostAddChild(AuthChild authChild) { GenericResponse genericResponse = new GenericResponse(); - if (authChild.SocSecNum == "111111111") + if (authChild.SessionID != "id") + { + return Unauthorized(); + } + else if (authChild.SocSecNum == "111111111") { genericResponse.Status = Status.Error; genericResponse.Body["reason"] = "SSN Already exists!"; } else { - genericResponse.Status = Status.Success; genericResponse.Body["childID"] = "asdfaasdas"; } diff --git a/CoviDok/Controllers/CaseController.cs b/CoviDok/Controllers/CaseController.cs index 11530a7..ddd248f 100644 --- a/CoviDok/Controllers/CaseController.cs +++ b/CoviDok/Controllers/CaseController.cs @@ -18,8 +18,8 @@ namespace CoviDok.Controllers public class CaseController : ControllerBase { // POST /api/Case/{id} - [HttpGet("{id}")] - public async Task> GetCase(string id, AuthGet auth) + [HttpPost("{id}")] + public async Task> PostGetCase(string id, AuthGet auth) { if (auth.SessionID != "a") return Unauthorized(); @@ -36,7 +36,7 @@ namespace CoviDok.Controllers } Case c = new Case { - Id = "asasadf", + Id = id, DoctorID = "hehegbvdesv", ParentID = "qgwenhjegh", ChildID = "egwbenbeb", @@ -57,7 +57,7 @@ namespace CoviDok.Controllers } // POST /api/Case/{id}/close - [HttpPost("{i}/close")] + [HttpPut("{id}/close")] public async Task PostClose(string id, CaseUpdate data) { if (data.SessionID != "a") return Unauthorized(); @@ -66,6 +66,7 @@ namespace CoviDok.Controllers } // POST /api/Case/filter + [HttpPost("filter")] public async Task> Filter(CaseFilter filters) { if (filters.SessionID != "a") return Unauthorized(); diff --git a/CoviDok/Controllers/DocController.cs b/CoviDok/Controllers/DocController.cs index 23c6a54..c02bd1b 100644 --- a/CoviDok/Controllers/DocController.cs +++ b/CoviDok/Controllers/DocController.cs @@ -17,13 +17,10 @@ namespace CoviDok.Controllers [HttpGet] public async Task> GetDoctors() { - GenericResponse genericResponse = new GenericResponse - { - Status = Status.Success - }; + GenericResponse genericResponse = new GenericResponse(); for (int i=5; i < 15; i++) { - string doc = "{ \"FirstName\": \"Dr. Schanniquah\", \"LastName\": \"The " + i + "th\"}"; + string doc = "{ \"firstName\": \"Dr. Schanniquah\", \"lastName\": \"The " + i + "th\"}"; genericResponse.Body[i.ToString()] = doc; } return genericResponse; @@ -33,14 +30,11 @@ namespace CoviDok.Controllers [HttpGet("{id}/assistants")] public async Task> GetAssistantsOfDoctor(string id) { - GenericResponse genericResponse = new GenericResponse - { - Status = Status.Success - }; - genericResponse.Body["DoctorID"] = id; + GenericResponse genericResponse = new GenericResponse(); + genericResponse.Body["doctorID"] = id; for (int i = 5; i < 15; i++) { - string doc = "{ \"FirstName\": \"Belisarius\", \"LastName\": \"The " + i + "th Cawl\"}"; + string doc = "{ \"firstName\": \"Belisarius\", \"lastName\": \"The " + i + "th Cawl\"}"; genericResponse.Body[i.ToString()] = doc; } return genericResponse; @@ -50,14 +44,11 @@ namespace CoviDok.Controllers [HttpGet("{id}/children")] public async Task> GetChildrenOfDoctor(string id) { - GenericResponse genericResponse = new GenericResponse - { - Status = Status.Success - }; - genericResponse.Body["DoctorID"] = id; + GenericResponse genericResponse = new GenericResponse(); + genericResponse.Body["doctorID"] = id; for (int i = 5; i < 15; i++) { - string doc = "{ \"FirstName\": \"Belisarius\", \"LastName\": \"The " + i + "th Cawl\"}"; + string doc = "{ \"firstName\": \"Belisarius\", \"lastName\": \"The " + i + "th Cawl\"}"; genericResponse.Body[i.ToString()] = doc; } return genericResponse; diff --git a/CoviDok/api/Request/AuthRegistration.cs b/CoviDok/api/Request/AuthRegistration.cs index 9ef8328..6dcb297 100644 --- a/CoviDok/api/Request/AuthRegistration.cs +++ b/CoviDok/api/Request/AuthRegistration.cs @@ -12,5 +12,9 @@ namespace CoviDok.Api.Request public string Email { get; set; } public string Password { get; set; } public Role Role { get; set; } + + public override string ToString() { + return FirstName+" " + LastName +"; "+Email +"|"+Password; + } } } diff --git a/CoviDok/data/Case.cs b/CoviDok/data/Case.cs index ac0dea6..5da7e6c 100644 --- a/CoviDok/data/Case.cs +++ b/CoviDok/data/Case.cs @@ -14,7 +14,7 @@ namespace CoviDok.data public CaseStatus CaseStatus { get; set; } - public ICollection updates = new List(); + public ICollection Updates { get; set; } public string Assignee { get; set; } @@ -23,6 +23,11 @@ namespace CoviDok.data public DateTime CreatedDate { get; set; } //amikor a taskot létrehozták public DateTime LastModificationDate { get; set; } + public Case() + { + Updates= new List(); + } + } public enum CaseStatus