Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- M O V I E :
- @model Aud1._1_MVC.Models.MovieRentals
- @{
- ViewBag.Title = "Random";
- }
- <h2>@Model.movie.Name<h2>
- <h5>Rating: @Model.movie.Rating</h5>
- <img src="@Model.movie.ImageUrl" />
- <h3>Rented: </h3>
- <ul>
- @{
- int i = 0;
- foreach (var client in Model.clients)
- {
- <li> <a href="ShowClient/@i">@client.Name , @client.ClenskaKarticka</a></li>
- i++;
- }
- }
- </ul>
- C L I E N T :
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Web;
- namespace Aud1._1_MVC.Models
- {
- public class Client
- {
- public int Id { get; set; }
- public string Name { get; set; }
- public string Address { get; set; }
- public string Phone { get; set; }
- public string ClenskaKarticka { get; set; }
- public int Age { get; set; }
- }
- }
- M O V I E R E N T A L S :
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Web;
- namespace Aud1._1_MVC.Models
- {
- public class MovieRentals
- {
- public Movie movie { get; set; }
- public List<Client> clients { get; set; }
- public MovieRentals()
- {
- clients=new List<Client>();
- }
- }
- }
- M O V I E C O N T R O L L E R
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Web;
- using System.Web.Mvc;
- using Aud1._1_MVC.Models;
- namespace Aud1._1_MVC.Controllers
- {
- public class MoviesController : Controller
- {
- public static Movie movie = new Movie()
- {
- Name ="Shrek!",
- Rating =5,
- DownloadURL ="test",
- ImageUrl = @"https://www.looper.com/img/gallery/things-only-adults-notice-in-shrek/intro-1573597941.jpg"
- };
- public static List<Client> clients = new List<Client>()
- {
- new Client()
- {
- Name="Ivana",
- ClenskaKarticka="203123",
- Address="Nekoja adresa",
- Age=20,
- Phone="075210307"
- },
- new Client()
- {
- Name="Ivona",
- ClenskaKarticka="19811",
- Address="Nekoja adresa2",
- Age=15,
- Phone="07210447"
- },
- new Client()
- {
- Name="Aleksandar",
- ClenskaKarticka="203412",
- Address="Nekoja adresa3",
- Age=29,
- Phone="071297221"
- }
- };
- public ActionResult Index()
- {
- return View();
- }
- public ActionResult Random()
- {
- MovieRentals model=new MovieRentals();
- model.clients = clients;
- model.movie = movie;
- return View(model);
- }
- public ActionResult ShowClient(int id)
- {
- var model=clients.ElementAt(id);
- return View(model);
- }
- }
- }
- R A N D O M V I E W:
- @model Aud1._1_MVC.Models.MovieRentals
- @{
- ViewBag.Title = "Random";
- }
- <h2>@Model.movie.Name<h2>
- <h5>Rating: @Model.movie.Rating</h5>
- <img src="@Model.movie.ImageUrl" />
- <h3>Rented: </h3>
- <ul>
- @{
- int i = 0;
- foreach (var client in Model.clients)
- {
- <li> <a href="ShowClient/@i">@client.Name , @client.ClenskaKarticka</a></li>
- i++;
- }
- }
- </ul>
- S H O W C L I E N T V I E W :
- @model Aud1._1_MVC.Models.Client
- @{
- ViewBag.Title = "ShowClient";
- }
- @if(Model.Age<18)
- {
- <h2 style="color:red">Potreben nadzor od roditel</h2>
- }
- <h2>@Model.Name , @Model.ClenskaKarticka </h2>
- <h5>Adresa: @Model.Address</h5>
- <h5>Phone number: @Model.Phone</h5>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement