I'm on an MVC web application, it takes entities from a separate data Model layer. As I'm working on the entity Movie, the Views use the
dataModelLayer.Movie model from the DataModelLayer.
As the Index will show a list of movies, I created a new model which represents a list of movies in order to implement the
Index action. I created this new class inside the DataModelLayer.
When I set
ListOfMovies listOfMovies = movies;
in the Index action implementation I got an error, I then let Visual Studio to make a conversion and now an operator appeared on the model class.
How should I implement this? Or should I change the Index action implementation?
What I have tried:
The Index action will show all the movies, implementation ->
public ActionResult Index(string searchTitle) {
List<Movie> movies= _movieProxy.GetAllMovies();
ListOfMovies listOfMovies = movies;
if (!String.IsNullOrEmpty(searchTitle))
{
movie= _movieProxy.GetMovieByOneOrMoreProperties(searchTitle);
}
return View(listOfMovies);
}
I wrote the following code on my ListOfMovies class:
public class ListOfMovies
{
public List<Movie> Movies{ get; set; }
}
but when I set
ListOfMovies listOfMovies = movies;
I got an error in the Index action implementation, so I let Visual Studio make a conversion and now the following code appeared on the model class:
public class ListOfMovies
{
public List<Movie> Movies{ get; set; }
public static implicit operator ListOfMovies(List<Movie> v)
{
throw new NotImplementedException();
}