public ActionResult NewComment(CommentsVM model) { var identity = User.Identity.Name; int?userID = Userrepo.GetID(identity); model.UserID = (int)userID; var photomodel = photorepo.ByID(model.PhotoID); model.DatePosted = DateTime.Now; if (ModelState.IsValid && User.Identity.IsAuthenticated) { var newComment = ModelMapper.ModelToEntity(model); repo.AddOrUpdate(newComment); return(RedirectToAction("Details", "Photo", photomodel)); } return(RedirectToAction("Details", "Photo", photomodel)); }
public ActionResult Details(PhotoVM photo) { var photoModel = ModelMapper.EntityToModel(repo.ByID(photo.id)); return(View(photoModel)); }