public ActionResult GetProfilePicture(int? id)
{
if(id != null)
{
var person = Repository.OfType<Person>().GetById(id.Value);
if (person.MainProfilePicture != null)
return File(person.MainProfilePicture, person.ContentType ?? "image/png");
}
// load the default image
var fs = new FileStream(Server.MapPath("~/Images/profilepicplaceholder.png"), FileMode.Open, FileAccess.Read);
var img = new byte[fs.Length];
fs.Read(img, 0, img.Length);
fs.Close();
return File(img, "image/png");
}