Browse Source

Make codebase compliant to recently added tests

master
Daniel Gyulai 4 years ago
parent
commit
374c8007de
  1. 13
      CoviDok/Api/GenericResponse.cs
  2. 7
      CoviDok/Api/Request/CaseFilter.cs
  3. 6
      CoviDok/Api/Response/FilteredCases.cs
  4. 2
      CoviDok/BLL/Tools.cs
  5. 14
      CoviDok/Controllers/AuthController.cs
  6. 9
      CoviDok/Controllers/CaseController.cs
  7. 25
      CoviDok/Controllers/DocController.cs
  8. 4
      CoviDok/api/Request/AuthRegistration.cs
  9. 7
      CoviDok/data/Case.cs

13
CoviDok/Api/GenericResponse.cs

@ -9,12 +9,19 @@ namespace CoviDok.Api
{ {
public int Version { get; set; } public int Version { get; set; }
public Status Status { get; set; } public Status Status { get; set; }
public Dictionary<string, string> Body = new Dictionary<string, string>(); public Dictionary<string, string> Body { get; set; }
public GenericResponse()
{
Body = new Dictionary<string, string>();
Version = 1;
Status = Status.Success;
}
} }
public enum Status public enum Status
{ {
Error, Success,
Success Error
} }
} }

7
CoviDok/Api/Request/CaseFilter.cs

@ -9,6 +9,11 @@ namespace CoviDok.Api.Request
public class CaseFilter public class CaseFilter
{ {
public string SessionID { get; set; } public string SessionID { get; set; }
public Dictionary<string, string> Filters = new Dictionary<string, string>(); public Dictionary<string, string> Filters { get; set; }
public CaseFilter()
{
Filters = new Dictionary<string, string>();
}
} }
} }

6
CoviDok/Api/Response/FilteredCases.cs

@ -8,6 +8,10 @@ namespace CoviDok.Api.Response
{ {
public class FilteredCases public class FilteredCases
{ {
public ICollection<Case> Cases = new List<Case>(); public ICollection<Case> Cases { get; set; }
public FilteredCases()
{
Cases = new List<Case>();
}
} }
} }

2
CoviDok/BLL/Tools.cs

@ -70,7 +70,7 @@ namespace CoviDok.BLL
Sender = RandomString(13), Sender = RandomString(13),
Id = RandomString(8) Id = RandomString(8)
}; };
c.updates.Add(u); c.Updates.Add(u);
} }
return c; return c;
} }

14
CoviDok/Controllers/AuthController.cs

@ -35,6 +35,7 @@ namespace CoviDok.Controllers
[HttpPost("register")] [HttpPost("register")]
public async Task<ActionResult<GenericResponse>> PostRegister(AuthRegistration authRegistration) public async Task<ActionResult<GenericResponse>> PostRegister(AuthRegistration authRegistration)
{ {
// System.Diagnostics.Debug.WriteLine(authRegistration.ToString());
GenericResponse genericResponse = new GenericResponse(); GenericResponse genericResponse = new GenericResponse();
if (authRegistration.Email == "a") if (authRegistration.Email == "a")
{ {
@ -43,11 +44,7 @@ namespace CoviDok.Controllers
} else if (authRegistration.Password == "1") } else if (authRegistration.Password == "1")
{ {
genericResponse.Status = Status.Error; genericResponse.Status = Status.Error;
genericResponse.Body["reason"] = "Password dows not meet complexity requirements!"; genericResponse.Body["reason"] = "Password does not meet complexity requirements!";
}
else
{
genericResponse.Status = Status.Success;
} }
return genericResponse; return genericResponse;
@ -58,14 +55,17 @@ namespace CoviDok.Controllers
public async Task<ActionResult<GenericResponse>> PostAddChild(AuthChild authChild) public async Task<ActionResult<GenericResponse>> PostAddChild(AuthChild authChild)
{ {
GenericResponse genericResponse = new GenericResponse(); GenericResponse genericResponse = new GenericResponse();
if (authChild.SocSecNum == "111111111") if (authChild.SessionID != "id")
{
return Unauthorized();
}
else if (authChild.SocSecNum == "111111111")
{ {
genericResponse.Status = Status.Error; genericResponse.Status = Status.Error;
genericResponse.Body["reason"] = "SSN Already exists!"; genericResponse.Body["reason"] = "SSN Already exists!";
} }
else else
{ {
genericResponse.Status = Status.Success;
genericResponse.Body["childID"] = "asdfaasdas"; genericResponse.Body["childID"] = "asdfaasdas";
} }

9
CoviDok/Controllers/CaseController.cs

@ -18,8 +18,8 @@ namespace CoviDok.Controllers
public class CaseController : ControllerBase public class CaseController : ControllerBase
{ {
// POST /api/Case/{id} // POST /api/Case/{id}
[HttpGet("{id}")] [HttpPost("{id}")]
public async Task<ActionResult<Case>> GetCase(string id, AuthGet auth) public async Task<ActionResult<Case>> PostGetCase(string id, AuthGet auth)
{ {
if (auth.SessionID != "a") return Unauthorized(); if (auth.SessionID != "a") return Unauthorized();
@ -36,7 +36,7 @@ namespace CoviDok.Controllers
} }
Case c = new Case Case c = new Case
{ {
Id = "asasadf", Id = id,
DoctorID = "hehegbvdesv", DoctorID = "hehegbvdesv",
ParentID = "qgwenhjegh", ParentID = "qgwenhjegh",
ChildID = "egwbenbeb", ChildID = "egwbenbeb",
@ -57,7 +57,7 @@ namespace CoviDok.Controllers
} }
// POST /api/Case/{id}/close // POST /api/Case/{id}/close
[HttpPost("{i}/close")] [HttpPut("{id}/close")]
public async Task<IActionResult> PostClose(string id, CaseUpdate data) public async Task<IActionResult> PostClose(string id, CaseUpdate data)
{ {
if (data.SessionID != "a") return Unauthorized(); if (data.SessionID != "a") return Unauthorized();
@ -66,6 +66,7 @@ namespace CoviDok.Controllers
} }
// POST /api/Case/filter // POST /api/Case/filter
[HttpPost("filter")]
public async Task<ActionResult<FilteredCases>> Filter(CaseFilter filters) public async Task<ActionResult<FilteredCases>> Filter(CaseFilter filters)
{ {
if (filters.SessionID != "a") return Unauthorized(); if (filters.SessionID != "a") return Unauthorized();

25
CoviDok/Controllers/DocController.cs

@ -17,13 +17,10 @@ namespace CoviDok.Controllers
[HttpGet] [HttpGet]
public async Task<ActionResult<GenericResponse>> GetDoctors() public async Task<ActionResult<GenericResponse>> GetDoctors()
{ {
GenericResponse genericResponse = new GenericResponse GenericResponse genericResponse = new GenericResponse();
{
Status = Status.Success
};
for (int i=5; i < 15; i++) 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; genericResponse.Body[i.ToString()] = doc;
} }
return genericResponse; return genericResponse;
@ -33,14 +30,11 @@ namespace CoviDok.Controllers
[HttpGet("{id}/assistants")] [HttpGet("{id}/assistants")]
public async Task<ActionResult<GenericResponse>> GetAssistantsOfDoctor(string id) public async Task<ActionResult<GenericResponse>> GetAssistantsOfDoctor(string id)
{ {
GenericResponse genericResponse = new GenericResponse GenericResponse genericResponse = new GenericResponse();
{ genericResponse.Body["doctorID"] = id;
Status = Status.Success
};
genericResponse.Body["DoctorID"] = id;
for (int i = 5; i < 15; i++) 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; genericResponse.Body[i.ToString()] = doc;
} }
return genericResponse; return genericResponse;
@ -50,14 +44,11 @@ namespace CoviDok.Controllers
[HttpGet("{id}/children")] [HttpGet("{id}/children")]
public async Task<ActionResult<GenericResponse>> GetChildrenOfDoctor(string id) public async Task<ActionResult<GenericResponse>> GetChildrenOfDoctor(string id)
{ {
GenericResponse genericResponse = new GenericResponse GenericResponse genericResponse = new GenericResponse();
{ genericResponse.Body["doctorID"] = id;
Status = Status.Success
};
genericResponse.Body["DoctorID"] = id;
for (int i = 5; i < 15; i++) 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; genericResponse.Body[i.ToString()] = doc;
} }
return genericResponse; return genericResponse;

4
CoviDok/api/Request/AuthRegistration.cs

@ -12,5 +12,9 @@ namespace CoviDok.Api.Request
public string Email { get; set; } public string Email { get; set; }
public string Password { get; set; } public string Password { get; set; }
public Role Role { get; set; } public Role Role { get; set; }
public override string ToString() {
return FirstName+" " + LastName +"; "+Email +"|"+Password;
}
} }
} }

7
CoviDok/data/Case.cs

@ -14,7 +14,7 @@ namespace CoviDok.data
public CaseStatus CaseStatus { get; set; } public CaseStatus CaseStatus { get; set; }
public ICollection<Update> updates = new List<Update>(); public ICollection<Update> Updates { get; set; }
public string Assignee { 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 CreatedDate { get; set; } //amikor a taskot létrehozták
public DateTime LastModificationDate { get; set; } public DateTime LastModificationDate { get; set; }
public Case()
{
Updates= new List<Update>();
}
} }
public enum CaseStatus public enum CaseStatus

Loading…
Cancel
Save