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 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
{
Error,
Success
Success,
Error
}
}

7
CoviDok/Api/Request/CaseFilter.cs

@ -9,6 +9,11 @@ namespace CoviDok.Api.Request
public class CaseFilter
{
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 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),
Id = RandomString(8)
};
c.updates.Add(u);
c.Updates.Add(u);
}
return c;
}

14
CoviDok/Controllers/AuthController.cs

@ -35,6 +35,7 @@ namespace CoviDok.Controllers
[HttpPost("register")]
public async Task<ActionResult<GenericResponse>> 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<ActionResult<GenericResponse>> 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";
}

9
CoviDok/Controllers/CaseController.cs

@ -18,8 +18,8 @@ namespace CoviDok.Controllers
public class CaseController : ControllerBase
{
// POST /api/Case/{id}
[HttpGet("{id}")]
public async Task<ActionResult<Case>> GetCase(string id, AuthGet auth)
[HttpPost("{id}")]
public async Task<ActionResult<Case>> 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<IActionResult> 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<ActionResult<FilteredCases>> Filter(CaseFilter filters)
{
if (filters.SessionID != "a") return Unauthorized();

25
CoviDok/Controllers/DocController.cs

@ -17,13 +17,10 @@ namespace CoviDok.Controllers
[HttpGet]
public async Task<ActionResult<GenericResponse>> 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<ActionResult<GenericResponse>> 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<ActionResult<GenericResponse>> 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;

4
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;
}
}
}

7
CoviDok/data/Case.cs

@ -14,7 +14,7 @@ namespace CoviDok.data
public CaseStatus CaseStatus { get; set; }
public ICollection<Update> updates = new List<Update>();
public ICollection<Update> 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<Update>();
}
}
public enum CaseStatus

Loading…
Cancel
Save