public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Categories category = repository.GetById(id); if (category == null) { return(HttpNotFound()); } return(View(category)); }