コード例 #1
0
        /// <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.
                // TODO Call method to check if the issue number is available for this comic book.

                if (_comicBooksRepository.ValidateComicBook(comicBook))
                {
                    ModelState.AddModelError("ComicBook.IssueNumber",
                                             "The provided Issue Number has already been entered for the selected Series.");
                }
            }
        }