Skip to content

Commit

Permalink
EXAM 04-APRIL-2019
Browse files Browse the repository at this point in the history
  • Loading branch information
SonicTheCat committed Apr 8, 2019
1 parent e91cf1e commit c39d419
Show file tree
Hide file tree
Showing 38 changed files with 5,122 additions and 0 deletions.
Binary file not shown.
25 changes: 25 additions & 0 deletions Exam-04-April-2019/Cinema.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.28307.106
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Cinema", "Cinema\Cinema.csproj", "{48DA9A16-0B45-4C96-9C1C-AE6433667B1F}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{48DA9A16-0B45-4C96-9C1C-AE6433667B1F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{48DA9A16-0B45-4C96-9C1C-AE6433667B1F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{48DA9A16-0B45-4C96-9C1C-AE6433667B1F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{48DA9A16-0B45-4C96-9C1C-AE6433667B1F}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {3BA85C81-DFC6-4D53-8B70-2E03A3758900}
EndGlobalSection
EndGlobal
16 changes: 16 additions & 0 deletions Exam-04-April-2019/Cinema/Cinema.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.1</TargetFramework>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="AutoMapper" Version="8.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Proxies" Version="2.2.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="2.2.0" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.1" />
</ItemGroup>


</Project>
12 changes: 12 additions & 0 deletions Exam-04-April-2019/Cinema/CinemaProfile.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using AutoMapper;

namespace Cinema
{
public class CinemaProfile : Profile
{
// Configure your AutoMapper here if you wish to use it. If not, DO NOT DELETE THIS CLASS
public CinemaProfile()
{
}
}
}
29 changes: 29 additions & 0 deletions Exam-04-April-2019/Cinema/Data/CinemaContext.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
namespace Cinema.Data
{
using Cinema.Data.Models;
using Microsoft.EntityFrameworkCore;

public class CinemaContext : DbContext
{
public CinemaContext() { }

public CinemaContext(DbContextOptions options)
: base(options) { }

public DbSet<Seat> Seats { get; set; }
public DbSet<Ticket> Tickets { get; set; }
public DbSet<Customer> Customers { get; set; }
public DbSet<Hall> Halls { get; set; }
public DbSet<Projection> Projections { get; set; }
public DbSet<Movie> Movies{ get; set; }

protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
if (!optionsBuilder.IsConfigured)
{
optionsBuilder
.UseSqlServer(Configuration.ConnectionString);
}
}
}
}
7 changes: 7 additions & 0 deletions Exam-04-April-2019/Cinema/Data/Configuration.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace Cinema.Data
{
public static class Configuration
{
public static string ConnectionString = @"Server=.;Database=Cinema;Trusted_Connection=True";
}
}
28 changes: 28 additions & 0 deletions Exam-04-April-2019/Cinema/Data/Models/Customer.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
namespace Cinema.Data.Models
{
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;

public class Customer
{
public int Id { get; set; }

[MinLength(3), MaxLength(20)]
[Required]
public string FirstName { get; set; }

[MinLength(3), MaxLength(20)]
[Required]
public string LastName { get; set; }

[Range(12,110)]
[Required]
public int Age { get; set; }

[Required]
[Range(typeof(decimal), "0.01", "79228162514264337593543950335")]
public decimal Balance { get; set; }

public ICollection<Ticket> Tickets { get; set; } = new HashSet<Ticket>();
}
}
16 changes: 16 additions & 0 deletions Exam-04-April-2019/Cinema/Data/Models/Enums/Genre.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
namespace Cinema.Data.Models.Enums
{
public enum Genre
{
Action,
Drama,
Comedy,
Crime,
Western,
Romance,
Documentary,
Children,
Animation,
Musical
}
}
24 changes: 24 additions & 0 deletions Exam-04-April-2019/Cinema/Data/Models/Hall.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
namespace Cinema.Data.Models
{
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;

public class Hall
{
public int Id { get; set; }

[Required]
[MinLength(3), MaxLength(20)]
public string Name { get; set; }

[Required]
public bool Is4Dx { get; set; }

[Required]
public bool Is3D { get; set; }

public ICollection<Projection> Projections { get; set; } = new HashSet<Projection>();

public ICollection<Seat> Seats { get; set; } = new HashSet<Seat>();
}
}
32 changes: 32 additions & 0 deletions Exam-04-April-2019/Cinema/Data/Models/Movie.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
namespace Cinema.Data.Models
{
using Cinema.Data.Models.Enums;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;

public class Movie
{
public int Id { get; set; }

[Required]
[MinLength(3), MaxLength(20)]
public string Title { get; set; }

[Required]
public Genre Genre { get; set; }

[Required]
public TimeSpan Duration { get; set; }

[Range(1, 10)]
[Required]
public double Rating { get; set; }

[Required]
[MinLength(3), MaxLength(20)]
public string Director { get; set; }

public ICollection<Projection> Projections { get; set; } = new HashSet<Projection>();
}
}
27 changes: 27 additions & 0 deletions Exam-04-April-2019/Cinema/Data/Models/Projection.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
namespace Cinema.Data.Models
{
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

public class Projection
{
public int Id { get; set; }

[Required]
[ForeignKey(nameof(Movie))]
public int MovieId { get; set; }
public Movie Movie { get; set; }

[ForeignKey(nameof(Hall))]
[Required]
public int HallId { get; set; }
public Hall Hall { get; set; }

[Required]
public DateTime DateTime { get; set; }

public ICollection<Ticket> Tickets { get; set; } = new HashSet<Ticket>();
}
}
15 changes: 15 additions & 0 deletions Exam-04-April-2019/Cinema/Data/Models/Seat.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
namespace Cinema.Data.Models
{
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

public class Seat
{
public int Id { get; set; }

[Required]
[ForeignKey(nameof(Hall))]
public int HallId { get; set; }
public Hall Hall { get; set; }
}
}
24 changes: 24 additions & 0 deletions Exam-04-April-2019/Cinema/Data/Models/Ticket.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
namespace Cinema.Data.Models
{
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

public class Ticket
{
public int Id { get; set; }

[Range(typeof(decimal), "0.01", "79228162514264337593543950335")]
[Required]
public decimal Price { get; set; }

[Required]
[ForeignKey(nameof(Customer))]
public int CustomerId { get; set; }
public Customer Customer { get; set; }

[Required]
[ForeignKey(nameof(Projection))]
public int ProjectionId { get; set; }
public Projection Projection { get; set; }
}
}
Loading

0 comments on commit c39d419

Please sign in to comment.