Ejemplo n.º 1
0
        /// <summary>
        /// Validates a comic book artist on the server
        /// before adding a new record.
        /// </summary>
        /// <param name="viewModel">The view model containing the values to validate.</param>
        private void ValidateComicBookArtist(ComicBookArtistsAddViewModel viewModel)
        {
            //// If there aren't any "ArtistId" and "RoleId" field validation errors...
            if (ModelState.IsValidField("ArtistId") &&
                ModelState.IsValidField("RoleId"))
            {
                // Then make sure that this artist and role combination
                // doesn't already exist for this comic book.

                if (_comicBooksRepository.ComicBookArtistsHasCombinationId(viewModel.ArtistId, viewModel.RoleId, viewModel.ComicBookId))
                {
                    ModelState.AddModelError("ArtistId",
                                             "This artist and role combination already exists for this comic book.");
                }
            }
        }