Skip to content

Commit c39d419

Browse files
committed
EXAM 04-APRIL-2019
1 parent e91cf1e commit c39d419

38 files changed

+5122
-0
lines changed
Binary file not shown.

Exam-04-April-2019/Cinema.sln

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio 15
4+
VisualStudioVersion = 15.0.28307.106
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Cinema", "Cinema\Cinema.csproj", "{48DA9A16-0B45-4C96-9C1C-AE6433667B1F}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Release|Any CPU = Release|Any CPU
12+
EndGlobalSection
13+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14+
{48DA9A16-0B45-4C96-9C1C-AE6433667B1F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{48DA9A16-0B45-4C96-9C1C-AE6433667B1F}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{48DA9A16-0B45-4C96-9C1C-AE6433667B1F}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{48DA9A16-0B45-4C96-9C1C-AE6433667B1F}.Release|Any CPU.Build.0 = Release|Any CPU
18+
EndGlobalSection
19+
GlobalSection(SolutionProperties) = preSolution
20+
HideSolutionNode = FALSE
21+
EndGlobalSection
22+
GlobalSection(ExtensibilityGlobals) = postSolution
23+
SolutionGuid = {3BA85C81-DFC6-4D53-8B70-2E03A3758900}
24+
EndGlobalSection
25+
EndGlobal
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFramework>netcoreapp2.1</TargetFramework>
6+
</PropertyGroup>
7+
8+
<ItemGroup>
9+
<PackageReference Include="AutoMapper" Version="8.0.0" />
10+
<PackageReference Include="Microsoft.EntityFrameworkCore.Proxies" Version="2.2.0" />
11+
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="2.2.0" />
12+
<PackageReference Include="Newtonsoft.Json" Version="12.0.1" />
13+
</ItemGroup>
14+
15+
16+
</Project>
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
using AutoMapper;
2+
3+
namespace Cinema
4+
{
5+
public class CinemaProfile : Profile
6+
{
7+
// Configure your AutoMapper here if you wish to use it. If not, DO NOT DELETE THIS CLASS
8+
public CinemaProfile()
9+
{
10+
}
11+
}
12+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
namespace Cinema.Data
2+
{
3+
using Cinema.Data.Models;
4+
using Microsoft.EntityFrameworkCore;
5+
6+
public class CinemaContext : DbContext
7+
{
8+
public CinemaContext() { }
9+
10+
public CinemaContext(DbContextOptions options)
11+
: base(options) { }
12+
13+
public DbSet<Seat> Seats { get; set; }
14+
public DbSet<Ticket> Tickets { get; set; }
15+
public DbSet<Customer> Customers { get; set; }
16+
public DbSet<Hall> Halls { get; set; }
17+
public DbSet<Projection> Projections { get; set; }
18+
public DbSet<Movie> Movies{ get; set; }
19+
20+
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
21+
{
22+
if (!optionsBuilder.IsConfigured)
23+
{
24+
optionsBuilder
25+
.UseSqlServer(Configuration.ConnectionString);
26+
}
27+
}
28+
}
29+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
namespace Cinema.Data
2+
{
3+
public static class Configuration
4+
{
5+
public static string ConnectionString = @"Server=.;Database=Cinema;Trusted_Connection=True";
6+
}
7+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
namespace Cinema.Data.Models
2+
{
3+
using System.Collections.Generic;
4+
using System.ComponentModel.DataAnnotations;
5+
6+
public class Customer
7+
{
8+
public int Id { get; set; }
9+
10+
[MinLength(3), MaxLength(20)]
11+
[Required]
12+
public string FirstName { get; set; }
13+
14+
[MinLength(3), MaxLength(20)]
15+
[Required]
16+
public string LastName { get; set; }
17+
18+
[Range(12,110)]
19+
[Required]
20+
public int Age { get; set; }
21+
22+
[Required]
23+
[Range(typeof(decimal), "0.01", "79228162514264337593543950335")]
24+
public decimal Balance { get; set; }
25+
26+
public ICollection<Ticket> Tickets { get; set; } = new HashSet<Ticket>();
27+
}
28+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
namespace Cinema.Data.Models.Enums
2+
{
3+
public enum Genre
4+
{
5+
Action,
6+
Drama,
7+
Comedy,
8+
Crime,
9+
Western,
10+
Romance,
11+
Documentary,
12+
Children,
13+
Animation,
14+
Musical
15+
}
16+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
namespace Cinema.Data.Models
2+
{
3+
using System.Collections.Generic;
4+
using System.ComponentModel.DataAnnotations;
5+
6+
public class Hall
7+
{
8+
public int Id { get; set; }
9+
10+
[Required]
11+
[MinLength(3), MaxLength(20)]
12+
public string Name { get; set; }
13+
14+
[Required]
15+
public bool Is4Dx { get; set; }
16+
17+
[Required]
18+
public bool Is3D { get; set; }
19+
20+
public ICollection<Projection> Projections { get; set; } = new HashSet<Projection>();
21+
22+
public ICollection<Seat> Seats { get; set; } = new HashSet<Seat>();
23+
}
24+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
namespace Cinema.Data.Models
2+
{
3+
using Cinema.Data.Models.Enums;
4+
using System;
5+
using System.Collections.Generic;
6+
using System.ComponentModel.DataAnnotations;
7+
8+
public class Movie
9+
{
10+
public int Id { get; set; }
11+
12+
[Required]
13+
[MinLength(3), MaxLength(20)]
14+
public string Title { get; set; }
15+
16+
[Required]
17+
public Genre Genre { get; set; }
18+
19+
[Required]
20+
public TimeSpan Duration { get; set; }
21+
22+
[Range(1, 10)]
23+
[Required]
24+
public double Rating { get; set; }
25+
26+
[Required]
27+
[MinLength(3), MaxLength(20)]
28+
public string Director { get; set; }
29+
30+
public ICollection<Projection> Projections { get; set; } = new HashSet<Projection>();
31+
}
32+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
namespace Cinema.Data.Models
2+
{
3+
using System;
4+
using System.Collections.Generic;
5+
using System.ComponentModel.DataAnnotations;
6+
using System.ComponentModel.DataAnnotations.Schema;
7+
8+
public class Projection
9+
{
10+
public int Id { get; set; }
11+
12+
[Required]
13+
[ForeignKey(nameof(Movie))]
14+
public int MovieId { get; set; }
15+
public Movie Movie { get; set; }
16+
17+
[ForeignKey(nameof(Hall))]
18+
[Required]
19+
public int HallId { get; set; }
20+
public Hall Hall { get; set; }
21+
22+
[Required]
23+
public DateTime DateTime { get; set; }
24+
25+
public ICollection<Ticket> Tickets { get; set; } = new HashSet<Ticket>();
26+
}
27+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
namespace Cinema.Data.Models
2+
{
3+
using System.ComponentModel.DataAnnotations;
4+
using System.ComponentModel.DataAnnotations.Schema;
5+
6+
public class Seat
7+
{
8+
public int Id { get; set; }
9+
10+
[Required]
11+
[ForeignKey(nameof(Hall))]
12+
public int HallId { get; set; }
13+
public Hall Hall { get; set; }
14+
}
15+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
namespace Cinema.Data.Models
2+
{
3+
using System.ComponentModel.DataAnnotations;
4+
using System.ComponentModel.DataAnnotations.Schema;
5+
6+
public class Ticket
7+
{
8+
public int Id { get; set; }
9+
10+
[Range(typeof(decimal), "0.01", "79228162514264337593543950335")]
11+
[Required]
12+
public decimal Price { get; set; }
13+
14+
[Required]
15+
[ForeignKey(nameof(Customer))]
16+
public int CustomerId { get; set; }
17+
public Customer Customer { get; set; }
18+
19+
[Required]
20+
[ForeignKey(nameof(Projection))]
21+
public int ProjectionId { get; set; }
22+
public Projection Projection { get; set; }
23+
}
24+
}

0 commit comments

Comments
 (0)