// // GET: /Profile/Delete/5 public ActionResult Delete(string id) { var profile = _provider.GetProfileByID(Guid.Parse(id)); ProfileViewModel model = new ProfileViewModel(profile); return View(model); }
// // GET: /Profile/Details/5 public ActionResult Details(string id) { Profile profile = _provider.GetProfileByID(Guid.Parse(id)); ProfileViewModel model = new ProfileViewModel(profile); if (profile.Photo != null && profile.Photo.Length > 0) { // Write photo to disk and set relative path to filename in a property within ProfileViewModel string path = Server.MapPath("~/Content/images"); string filename = profile.ID.ToString(); string extension = profile.PhotoMimeType; string fullFilename = string.Format(@"{0}\{1}.{2}", path, filename, "jpg"); System.IO.FileStream fs = null; System.IO.BinaryWriter bw = null; try { fs = new System.IO.FileStream(fullFilename, System.IO.FileMode.Create); bw = new System.IO.BinaryWriter(fs); bw.Write(profile.Photo); bw.Flush(); } catch { } finally { if (bw != null) bw.Close(); if (fs != null) fs.Close(); } model.PhotoUrl = "/Babylon.Site/Content/images/" + filename + ".jpg"; } else { model.PhotoUrl = "/Babylon.Site/Content/images/blank_profile.jpg"; } return View(model); }