예제 #1
0
        public static Tuple <bool, string> ValidateDirectorModel(FilmModel film)
        {
            if (film.Director == null)
            {
                return(Tuple.Create(false, "Director required"));
            }

            if (string.IsNullOrEmpty(film.Director.FirstName) || string.IsNullOrEmpty(film.Director.LastName))
            {
                return(Tuple.Create(false, "Directors name invalid"));
            }

            if (film.Director.Films != null && film.Director.Films.Count() > 0)
            {
                return(Tuple.Create(false, $"Director's entity {film.Director.FirstName} {film.Director.LastName} contains films. " +
                                    "Adding films for a particular director is not supported by films controller. " +
                                    "If you want to update/add films to director's entity please use directors controller"));
            }

            return(Tuple.Create(true, ""));
        }
예제 #2
0
        public static Tuple <bool, string> ValidateActorModels(FilmModel film)
        {
            if (film.Cast != null && film.Cast.Count() > 0)
            {
                var actors = film.Cast;
                foreach (var actor in actors)
                {
                    if (string.IsNullOrEmpty(actor.FirstName) || string.IsNullOrEmpty(actor.LastName))
                    {
                        return(Tuple.Create(false, $"{actor.FirstName} {actor.LastName} invalid"));
                    }

                    if (actor.Films != null && actor.Films.Count() > 0)
                    {
                        return(Tuple.Create(false, $"{actor.FirstName} {actor.LastName} contains films. " +
                                            $"Adding films for a particular actor is not supported by films controller. " +
                                            $"If you want to add films to actor's entity please use actors controller or AddActorToCast method"));
                    }
                }
            }
            return(Tuple.Create(true, ""));
        }