public ActionResult AddNew() { List <BlogEntry> all = repo.GetAll(); foreach (BlogEntry x in repo.GetQueue()) { all.Add(x); } int index = 1; foreach (BlogEntry x in all) { if (x.BlogId >= index) { index = x.BlogId + 1; } } BlogEntry model = new BlogEntry() { BlogId = index }; return(View(model)); }