public ActionResult Details(int id) { var objStudentRepository = new GalleryRepository(); var objEntity = new GalleryViewModel(); objEntity = objStudentRepository.Select(GalleryFlags.SelectByID.GetHashCode(), new GalleryViewModel() { Id = id }).FirstOrDefault(); if (objEntity == null) { return(RedirectToAction("Index")); } return(View(objEntity)); }