/// <summary> /// Validates a comic book on the server /// before adding a new record or updating an existing record. /// </summary> /// <param name="comicBook">The comic book to validate.</param> private void ValidateComicBook(ComicBook comicBook) { // If there aren't any "SeriesId" and "IssueNumber" field validation errors... if (ModelState.IsValidField("ComicBook.SeriesId") && ModelState.IsValidField("ComicBook.IssueNumber")) { // Then make sure that the provided issue number is unique for the provided series. if (_comicBooksRepository.SeriesHasIssueNumber(comicBook.Id, comicBook.SeriesId, comicBook.IssueNumber)) { ModelState.AddModelError("ComicBook.IssueNumber", "The provided Issue Number has already been entered for the selected Series."); } } }