User1644755831 posted
Hello atplerry01,
you could add an overload to get method in LocalPhotoManager class
public async Task<PhotoViewModel> Get(int ID)
{
PhotoViewModel photo = new PhotoViewModel();
DirectoryInfo photoFolder = new DirectoryInfo(this.workingFolder);
await Task.Factory.StartNew(() =>
{
photo = photoFolder.EnumerateFiles()
.Where(fi => new[] { ".jpg", ".bmp", ".png", ".gif", ".tiff" }.Contains(fi.Extension.ToLower()) && fi.id == ID)
.Select(fi => new PhotoViewModel
{
Name = fi.Name,
Created = fi.CreationTime,
Modified = fi.LastWriteTime,
Size = fi.Length / 1024 //if you want more properties like image extend your model and add the image here
})
.FirstOrDefault();
});
return photo;
}
then in controller get the photo by id
// GET: api/Photo/ID
public async Task<IHttpActionResult> Get(int ID)
{
var results = await photoManager.Get(ID);
return Ok(new { photo = results });
}
Hope this helps,
With Regards,
Krunal Parekh