private bool HasValidTitle(PreviewContentModel model, int? contentId) { var content = new Content(); content.GetContentByKey(FromString.UrlKey(model.PreviewTitle)); if (content.ContentID == 0 || (contentId != null && Convert.ToInt32(contentId) == content.ContentID)) return true; // already exists ModelState.AddModelError("PreviewTitle", "An article with this title already exists"); return false; }