Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions api-cinema-challenge/api-cinema-challenge.sln
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{3C371BAA-344D-4C8A-AF08-7829816D726F}"
ProjectSection(SolutionItems) = preProject
..\.gitignore = ..\.gitignore
..\..\..\..\Downloads\Cinema.drawio.png = ..\..\..\..\Downloads\Cinema.drawio.png
..\README.md = ..\README.md
EndProjectSection
EndProject
Expand Down
21 changes: 21 additions & 0 deletions api-cinema-challenge/api-cinema-challenge/DTO/ApiResponse.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
namespace api_cinema_challenge.DTO
{
public class ApiResponse<T>
{
public string Status { get; set; } = "success";
public T Data { get; set; }
//public string? ErrorMessage { get; set; }


public ApiResponse(T data)
{
Data = data;
}

public ApiResponse()
{
Status = "failed";
//ErrorMessage = error;
}
}
}
12 changes: 12 additions & 0 deletions api-cinema-challenge/api-cinema-challenge/DTO/CustomerGet.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
namespace api_cinema_challenge.DTO
{
public class CustomerGet
{
public int Id { get; set; }
public string Name { get; set; }
public string Email { get; set; }
public string Phone { get; set; }
public DateTime CreatedAt { get; set; }
public DateTime? UpdatedAt { get; set; }
}
}
9 changes: 9 additions & 0 deletions api-cinema-challenge/api-cinema-challenge/DTO/CustomerPost.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
namespace api_cinema_challenge.DTO
{
public class CustomerPost
{
public string Name { get; set; }
public string Email { get; set; }
public string Phone { get; set; }
}
}
9 changes: 9 additions & 0 deletions api-cinema-challenge/api-cinema-challenge/DTO/CustomerPut.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
namespace api_cinema_challenge.DTO
{
public class CustomerPut
{
public string? Name { get; set; }
public string? Email { get; set; }
public string? Phone { get; set; }
}
}
13 changes: 13 additions & 0 deletions api-cinema-challenge/api-cinema-challenge/DTO/MovieGet.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
namespace api_cinema_challenge.DTO
{
public class MovieGet
{
public int Id { get; set; }
public string? Title { get; set; }
public string? Rating { get; set; }
public string? Description { get; set; }
public int RuntimeMins { get; set; }
public DateTime CreatedAt { get; set; }
public DateTime? UpdatedAt { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
namespace api_cinema_challenge.DTO
{
public class MovieGetScreenings
{
public int Id { get; set; }
public string? Title { get; set; }
public string? Rating { get; set; }
public string? Description { get; set; }
public int RuntimeMins { get; set; }
public DateTime CreatedAt { get; set; }
public DateTime? UpdatedAt { get; set; }
public ICollection<ScreeningGet> Screenings { get; set; } = new List<ScreeningGet>();

}
}
12 changes: 12 additions & 0 deletions api-cinema-challenge/api-cinema-challenge/DTO/MoviePost.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
namespace api_cinema_challenge.DTO
{
public class MoviePost
{
public string Title { get; set; }
public string Rating { get; set; }
public string Description { get; set; }
public int RuntimeMins { get; set; }

public ICollection<ScreeningPost> Screenings { get; set; } = new List<ScreeningPost>();
}
}
10 changes: 10 additions & 0 deletions api-cinema-challenge/api-cinema-challenge/DTO/MoviePut.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
namespace api_cinema_challenge.DTO
{
public class MoviePut
{
public string? Title { get; set; }
public string? Rating { get; set; }
public string? Description { get; set; }
public int RuntimeMins { get; set; }
}
}
12 changes: 12 additions & 0 deletions api-cinema-challenge/api-cinema-challenge/DTO/ScreeningGet.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
namespace api_cinema_challenge.DTO
{
public class ScreeningGet
{
public int Id { get; set; }
public int ScreenNumber { get; set; }
public int Capacity { get; set; }
public DateTime StartsAt { get; set; }
public DateTime CreatedAt { get; set; }
public DateTime UpdatedAt { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
namespace api_cinema_challenge.DTO
{
public class ScreeningPost
{
public int ScreenNumber { get; set; }
public int Capacity { get; set; }
public DateTime StartsAt { get; set; }
}
}
10 changes: 10 additions & 0 deletions api-cinema-challenge/api-cinema-challenge/DTO/TicketGet.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
namespace api_cinema_challenge.DTO
{
public class TicketGet
{
public int Id { get; set; }
public int NumSeats { get; set; }
public DateTime CreatedAt { get; set; }
public DateTime UpdatedAt { get; set; }
}
}
7 changes: 7 additions & 0 deletions api-cinema-challenge/api-cinema-challenge/DTO/TicketPost.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace api_cinema_challenge.DTO
{
public class TicketPost
{
public int NumSeats { get; set; }
}
}
19 changes: 16 additions & 3 deletions api-cinema-challenge/api-cinema-challenge/Data/CinemaContext.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
using Microsoft.EntityFrameworkCore;
using api_cinema_challenge.Models;
using Microsoft.EntityFrameworkCore;
using Newtonsoft.Json.Linq;
using System.Diagnostics;
using System.Numerics;

namespace api_cinema_challenge.Data
{
Expand All @@ -9,18 +12,28 @@ public class CinemaContext : DbContext
public CinemaContext(DbContextOptions<CinemaContext> options) : base(options)
{
var configuration = new ConfigurationBuilder().AddJsonFile("appsettings.json").Build();
_connectionString = configuration.GetValue<string>("ConnectionStrings:DefaultConnectionString")!;
_connectionString = configuration.GetValue<string>("ConnectionStrings:DefaultConnection")!;
this.Database.EnsureCreated();
}

protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
optionsBuilder.UseNpgsql(_connectionString);
//optionsBuilder.LogTo(message => Debug.WriteLine(message));
}

protected override void OnModelCreating(ModelBuilder modelBuilder)
{

Seeder seeder = new Seeder();
modelBuilder.Entity<Customer>().HasData(seeder.Customers);
modelBuilder.Entity<Movie>().HasData(seeder.Movies);
modelBuilder.Entity<Screening>().HasData(seeder.Screenings);
modelBuilder.Entity<Ticket>().HasData(seeder.Tickets);
}

public DbSet<Customer> Customers { get; set; }
public DbSet<Movie> Movie { get; set; }
public DbSet<Screening> Screening { get; set; }
public DbSet<Ticket> Ticket { get; set; }
}
}
Loading