public ActionResult Save(long userId, HttpPostedFileBase profileImage)
{
string imagePath = null;
if (profileImage != null && profileImage.ContentLength > 0)
{
var imageFileName = Path.GetFileName(profileImage.FileName);
imagePath = FileHelper.NextAvailableFilename(Path.Combine(Server.MapPath(ConfigurationManager.AppSettings["UsersImgPath"]), imageFileName));
profileImage.SaveAs(imagePath);
imagePath = Path.GetFileName(imagePath);
}
var user = userMgr.ReadUser(userId);
user.ImageUrl = imagePath;
userMgr.UpdateUser(user);
return RedirectToAction("Index", "Home");
}