[HttpGet("resume/projects/{id}")]
public async Task<ActionResult<string>> Projects(int id)
{ // TODO: Going straight to DocumentIdExceptionNotFound Error, when the Id exists
try
{
var response = await this.dbService.GetProject(id);
return Ok(response);
}
catch (BsonSerializationException ex)
{
Console.WriteLine(ex.Message);
return Problem("Internal server error.");
}
catch (DocumentIdNotFoundException ex)
{
return NotFound(ex.Message);
}
catch (NullReferenceException ex)
{
System.Console.WriteLine($" Target = Project Collection: {ex.Message}");
return Problem("Internal Service Error");
}
catch (MongoConnectionException ex)
{
System.Console.WriteLine($" Target = Project Collection: {ex.Message}");
return Problem("Internal Service Error");
}
}
public async Task<string> GetExperience(int id) // Return document based on Id
{
var size = await this.experienceCollection.GetSize();
var validation = this.inputToMongoDBService.CheckIdRange(id, size);
if (validation)
{
var document = await this.experienceCollection.collection.Find(experienceCollection => experienceCollection.Id == id).FirstOrDefaultAsync();
var json = document.ToJson();
return json;
throw new DocumentIdNotFoundException();
}
else
{
throw new DocumentIdNotFoundException();
}
}