public virtual ActionResult ProfileImageEdit() { ImageSelectViewModel model = new ImageSelectViewModel(); model.Images = db.Images.Where(image => image.CreatedBy.Id == CurrentUser.Id).ToList(); //model.ShouldSetAsProfile = !model.Images.Any() && CurrentUser.Id == Target.Id; return(View(model)); }
public virtual ActionResult ProfileImageEdit(ImageSelectViewModel model) { Image image = db.Images.Find(model.SelectedImageId); if (image != null) { Target.ProfilePicture = image; db.SaveChanges(); } return(RedirectToAction(Actions.Edit().WithId(Target))); }