public ActionResult AddImage(Image image) { if (User.Identity.IsAuthenticated) { image.User = User.Identity.Name; } image.UploadDate = DateTime.Now; if (ModelState.IsValid) { repository.AddImage(image); repository.SaveChanges(); } return(RedirectToAction("Index")); }